@quadient/skillshare 1.19.2 → 1.20.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 +1 -1
- package/dist/help.js +4 -3
- package/dist/index.js +10 -11
- package/dist/output.js +16 -1
- package/dist/pages-dev-tools.js +4 -4
- package/dist/pages-runtime.js +66 -0
- package/dist/teams-auth.js +88 -19
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -397,7 +397,7 @@ bunx @quadient/skillshare@^1.6.0 pages dev . --slug my-app
|
|
|
397
397
|
```
|
|
398
398
|
|
|
399
399
|
The directory must contain one `wrangler.json` or `wrangler.jsonc`. The CLI downloads
|
|
400
|
-
and verifies celld 0.6.
|
|
400
|
+
and verifies celld 0.6.3 on first use, caches it under `~/.cache/skillshare/celld`,
|
|
401
401
|
and uses its packaged esbuild. Supported hosts are macOS Apple Silicon and Linux
|
|
402
402
|
x64/ARM64; Windows users can use WSL2. `--celld <executable>` or `CELLD_EXECUTABLE`
|
|
403
403
|
selects an existing installation.
|
package/dist/help.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
export const GLOBAL_FLAGS = ['token', 'server', 'help'];
|
|
3
|
-
export const BOOLEAN_FLAGS = new Set(['all', 'digest', 'disabled', 'dry-run', 'force', 'headless', 'help', 'json', 'keep-unread', 'no-teams-watch', 'no-update', 'notify-again', 'original', 'owners-only', 'resolved', 'review', 'sandbox', 'unread']);
|
|
3
|
+
export const BOOLEAN_FLAGS = new Set(['all', 'digest', 'disabled', 'dry-run', 'force', 'headless', 'help', 'json', 'keep-unread', 'no-teams-watch', 'no-update', 'notify-again', 'original', 'external', 'internal', 'always-on', 'owners-only', 'resolved', 'review', 'sandbox', 'unread']);
|
|
4
4
|
export const COMMANDS = [
|
|
5
5
|
{
|
|
6
6
|
name: 'login',
|
|
@@ -86,6 +86,7 @@ export const COMMANDS = [
|
|
|
86
86
|
'pages list [--json]',
|
|
87
87
|
'pages show <slug> [--json]',
|
|
88
88
|
'pages runtime <slug> [--json]',
|
|
89
|
+
'pages runtime set <slug> [--external|--internal] [--min <MiB>] [--max <MiB>] [--always-on true|false] [--json]',
|
|
89
90
|
'pages upload <directory> [--slug <slug>] [--json]',
|
|
90
91
|
'pages secrets list <slug> [--json]',
|
|
91
92
|
'pages secrets set <slug> <name> [--json]',
|
|
@@ -98,9 +99,9 @@ export const COMMANDS = [
|
|
|
98
99
|
'pages dev [directory] [--slug <slug>] [--port <port>] [--build <command> --watch-dir <sources>]',
|
|
99
100
|
' [--celld <executable>] [--user-id <id>] [--user-name <name>] [--user-email <email>]',
|
|
100
101
|
],
|
|
101
|
-
description: 'An upload replaces all content of the page. Without --slug the directory name is used; build output folders such as dist need an explicit --slug. Pages owned by someone else are refused unless you are an admin. pages secrets manages the write-only secrets an app reads through SKILLSHARE_SECRETS (owner or admin only, at most 32 per page, 16 KiB each); set reads the value from piped stdin or a masked prompt, never from the command line. pages comments reads and writes the annotations reviewers leave on a Page at /pa/<slug>/ (enable and disable decide whether the regular /p/<slug>/ address shows them too); add creates a page note, text without an argument (or -) is read from stdin, and list hides resolved threads unless --resolved is given.',
|
|
102
|
+
description: 'An upload replaces all content of the page. Without --slug the directory name is used; build output folders such as dist need an explicit --slug. Pages owned by someone else are refused unless you are an admin. pages secrets manages the write-only secrets an app reads through SKILLSHARE_SECRETS (owner or admin only, at most 32 per page, 16 KiB each); set reads the value from piped stdin or a masked prompt, never from the command line. pages runtime set is for administrators: --external moves the app into its own pod (its data is copied, the app is briefly unavailable), --internal back into SkillShare; external apps get memory automatically between --min and --max MiB, and --always-on keeps an app running without traffic. pages comments reads and writes the annotations reviewers leave on a Page at /pa/<slug>/ (enable and disable decide whether the regular /p/<slug>/ address shows them too); add creates a page note, text without an argument (or -) is read from stdin, and list hides resolved threads unless --resolved is given.',
|
|
102
103
|
examples: ['skillshare pages upload ./site --slug release-notes', 'skillshare pages dev . --slug my-app', 'skillshare pages secrets set my-app API_TOKEN', 'printf %s "$TOKEN" | skillshare pages secrets set my-app API_TOKEN', 'skillshare pages comments list my-app --author mine', 'skillshare pages comments reply my-app 12 "Fixed in revision 4"'],
|
|
103
|
-
flags: ['slug', 'path', 'author', 'resolved', 'json'],
|
|
104
|
+
flags: ['slug', 'path', 'author', 'resolved', 'external', 'internal', 'min', 'max', 'always-on', 'json'],
|
|
104
105
|
},
|
|
105
106
|
{
|
|
106
107
|
name: 'teams',
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,11 @@ import { findCommand, readCliVersion, renderCommandHelp, renderUsage } from './h
|
|
|
10
10
|
import { inspectInstallTarget, installFilesAtomically } from './install-files.js';
|
|
11
11
|
import { formatRemovedSkillCleanup, offerRemovedSkillUninstalls } from './removed-skills.js';
|
|
12
12
|
import { preparePageFiles, resolvePageSlug } from './pages.js';
|
|
13
|
-
import { formatByteSize, formatDateTime, pageUrl, plural, renderPageDetail, renderPageList,
|
|
13
|
+
import { formatByteSize, formatDateTime, pageUrl, plural, renderPageDetail, renderPageList, renderSkillDetail, renderSkillList, renderSkillVersion, renderUser, } from './output.js';
|
|
14
14
|
import { runPageDev } from './pages-dev.js';
|
|
15
15
|
import { runPageCommentsCommand } from './pages-comments.js';
|
|
16
16
|
import { runPageSecretsCommand } from './pages-secrets.js';
|
|
17
|
+
import { runPageRuntimeCommand } from './pages-runtime.js';
|
|
17
18
|
import { waitForLoginCallback } from './login-callback.js';
|
|
18
19
|
import { createHash, randomBytes } from 'node:crypto';
|
|
19
20
|
import { spawn } from 'node:child_process';
|
|
@@ -368,18 +369,16 @@ async function main() {
|
|
|
368
369
|
print(pages, () => renderPageList(pages));
|
|
369
370
|
return;
|
|
370
371
|
}
|
|
371
|
-
if (action === '
|
|
372
|
+
if (action === 'runtime') {
|
|
373
|
+
await runPageRuntimeCommand(client, options.positionals.slice(1), options.flags, print);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (action === 'show') {
|
|
372
377
|
const slug = options.positionals[1];
|
|
373
378
|
if (!slug)
|
|
374
|
-
throw new Error(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
print(page, () => renderPageDetail(page, client.baseUrl));
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
const runtime = await client.get(`/api/pages/${encodeURIComponent(slug)}/runtime`);
|
|
381
|
-
print(runtime, () => renderPageRuntime(slug, runtime));
|
|
382
|
-
}
|
|
379
|
+
throw new Error('pages show requires <slug>');
|
|
380
|
+
const page = await client.get(`/api/pages/${encodeURIComponent(slug)}`);
|
|
381
|
+
print(page, () => renderPageDetail(page, client.baseUrl));
|
|
383
382
|
return;
|
|
384
383
|
}
|
|
385
384
|
if (action === 'upload') {
|
package/dist/output.js
CHANGED
|
@@ -135,11 +135,26 @@ export function renderPageDetail(page, baseUrl, now = new Date()) {
|
|
|
135
135
|
].join('\n');
|
|
136
136
|
}
|
|
137
137
|
export function renderPageRuntime(slug, runtime, logLimit = 20) {
|
|
138
|
+
const settings = runtime.settings;
|
|
138
139
|
const lines = [
|
|
139
|
-
`${slug}: ${runtime.state} · revision ${runtime.revision}${runtime.processId ? ` · pid ${runtime.processId}` : ''}`,
|
|
140
|
+
`${slug}: ${runtime.state} · revision ${runtime.revision}${runtime.processId ? ` · pid ${runtime.processId}` : ''}${settings ? ` · ${settings.placement}` : ''}`,
|
|
140
141
|
];
|
|
141
142
|
if (runtime.error)
|
|
142
143
|
lines.push(`Error: ${runtime.error}`);
|
|
144
|
+
if (settings) {
|
|
145
|
+
lines.push(`Always on: ${settings.alwaysOn ? 'yes' : 'no'}`);
|
|
146
|
+
if (settings.placement === 'external') {
|
|
147
|
+
const memory = runtime.memory;
|
|
148
|
+
const usage = [
|
|
149
|
+
memory?.currentMiB != null ? `using ${memory.currentMiB} MiB` : null,
|
|
150
|
+
memory?.peakMiB != null ? `4-day peak ${memory.peakMiB} MiB` : null,
|
|
151
|
+
memory?.outOfMemoryCount ? `${memory.outOfMemoryCount} out of memory` : null,
|
|
152
|
+
].filter(Boolean);
|
|
153
|
+
lines.push(`Memory: ${settings.limitMiB} MiB, automatic within ${settings.minMiB}–${settings.maxMiB} MiB · CPU ${settings.cpuRequestMilli}m${usage.length ? ` · ${usage.join(' · ')}` : ''}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (runtime.logsUrl)
|
|
157
|
+
lines.push(`Pod logs: ${runtime.logsUrl}`);
|
|
143
158
|
if (runtime.logs.length > 0) {
|
|
144
159
|
const shown = runtime.logs.slice(-logLimit);
|
|
145
160
|
lines.push('', `Last ${shown.length} of ${runtime.logs.length} log lines${runtime.logs.length > shown.length ? ' (use --json for all)' : ''}:`, ...shown);
|
package/dist/pages-dev-tools.js
CHANGED
|
@@ -3,19 +3,19 @@ import { chmod, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'
|
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
import { gunzipSync } from 'node:zlib';
|
|
6
|
-
const release = '0.6.
|
|
6
|
+
const release = '0.6.3';
|
|
7
7
|
const platforms = {
|
|
8
8
|
'darwin-arm64': [
|
|
9
9
|
'aarch64-apple-darwin',
|
|
10
|
-
'
|
|
10
|
+
'2df6b08369345db8c1f9a5edcf3932cecaa6fb35f4658575a6db17df28c22371',
|
|
11
11
|
],
|
|
12
12
|
'linux-x64': [
|
|
13
13
|
'x86_64-unknown-linux-gnu',
|
|
14
|
-
'
|
|
14
|
+
'5084a083472cf036551a7eac63fa24d22bb9a56323c517f63205724c12783047',
|
|
15
15
|
],
|
|
16
16
|
'linux-arm64': [
|
|
17
17
|
'aarch64-unknown-linux-gnu',
|
|
18
|
-
'
|
|
18
|
+
'6d617cdf9f049e43ca6a4e37c4cce5d8e35395c8e86b371c984d32ba7d803bf5',
|
|
19
19
|
],
|
|
20
20
|
};
|
|
21
21
|
export async function ensureCelld(override, signal) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { renderPageRuntime } from './output.js';
|
|
2
|
+
/**
|
|
3
|
+
* `pages runtime <slug>` shows the runtime to its owner or an administrator; `pages runtime set <slug>`
|
|
4
|
+
* lets an administrator move it between SkillShare and its own pod and set its automatic memory range.
|
|
5
|
+
*/
|
|
6
|
+
export async function runPageRuntimeCommand(client, positionals, flags, print) {
|
|
7
|
+
if (positionals[0] === 'set' && positionals[1]) {
|
|
8
|
+
const slug = positionals[1];
|
|
9
|
+
const body = settingsRequest(flags);
|
|
10
|
+
if (Object.keys(body).length === 0) {
|
|
11
|
+
throw new Error('pages runtime set needs --external, --internal, --min <MiB>, --max <MiB> or --always-on true|false');
|
|
12
|
+
}
|
|
13
|
+
const settings = await expect(slug, await client.request(`/api/pages/${encodeURIComponent(slug)}/runtime-settings`, {
|
|
14
|
+
method: 'PUT',
|
|
15
|
+
headers: { 'Content-Type': 'application/json' },
|
|
16
|
+
body: JSON.stringify(body),
|
|
17
|
+
}));
|
|
18
|
+
print(settings, () => `Updated /p/${slug}/: ${settings.placement}, always on ${settings.alwaysOn ? 'yes' : 'no'}, memory ${settings.minMiB}–${settings.maxMiB} MiB (now ${settings.limitMiB} MiB).`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const slug = positionals[0];
|
|
22
|
+
if (!slug)
|
|
23
|
+
throw new Error('pages runtime requires <slug>');
|
|
24
|
+
const runtime = await expect(slug, await client.request(`/api/pages/${encodeURIComponent(slug)}/runtime`, { method: 'GET' }));
|
|
25
|
+
print(runtime, () => renderPageRuntime(slug, runtime));
|
|
26
|
+
}
|
|
27
|
+
export function settingsRequest(flags) {
|
|
28
|
+
const body = {};
|
|
29
|
+
const external = isTrue(flags.external);
|
|
30
|
+
const internal = isTrue(flags.internal);
|
|
31
|
+
if (external && internal)
|
|
32
|
+
throw new Error('Use either --external or --internal.');
|
|
33
|
+
if (external)
|
|
34
|
+
body.placement = 'external';
|
|
35
|
+
if (internal)
|
|
36
|
+
body.placement = 'internal';
|
|
37
|
+
if (flags.min !== undefined)
|
|
38
|
+
body.minMiB = mebibytes('--min', flags.min);
|
|
39
|
+
if (flags.max !== undefined)
|
|
40
|
+
body.maxMiB = mebibytes('--max', flags.max);
|
|
41
|
+
if (flags['always-on'] !== undefined)
|
|
42
|
+
body.alwaysOn = isTrue(flags['always-on']);
|
|
43
|
+
return body;
|
|
44
|
+
}
|
|
45
|
+
function isTrue(value) {
|
|
46
|
+
return value !== undefined && !['0', 'false', 'no', 'off'].includes(value.toLowerCase());
|
|
47
|
+
}
|
|
48
|
+
function mebibytes(flag, value) {
|
|
49
|
+
if (!/^\d+$/.test(value))
|
|
50
|
+
throw new Error(`${flag} takes a whole number of MiB, for example ${flag} 500.`);
|
|
51
|
+
return Number(value);
|
|
52
|
+
}
|
|
53
|
+
async function expect(slug, response) {
|
|
54
|
+
if (response.ok)
|
|
55
|
+
return await response.json();
|
|
56
|
+
if (response.status === 403)
|
|
57
|
+
throw new Error(`Only an administrator can change the runtime of /p/${slug}/; its owner can view it.`);
|
|
58
|
+
if (response.status === 404)
|
|
59
|
+
throw new Error(`Page /p/${slug}/ was not found.`);
|
|
60
|
+
let error = {};
|
|
61
|
+
try {
|
|
62
|
+
error = await response.json();
|
|
63
|
+
}
|
|
64
|
+
catch { }
|
|
65
|
+
throw new Error(error.error ?? `Skillshare returned HTTP ${response.status} for the Page runtime.`);
|
|
66
|
+
}
|
package/dist/teams-auth.js
CHANGED
|
@@ -14,7 +14,7 @@ export function decodeTeamsJwt(value) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
/** Select only credentials belonging to the Skillshare account. No full browser state leaves this machine. */
|
|
17
|
-
export function extractTeamsSession(state, expectedObjectId, now = Date.now(), allowExpired = false) {
|
|
17
|
+
export function extractTeamsSession(state, expectedObjectId, now = Date.now(), allowExpired = false, skypeOptional = false) {
|
|
18
18
|
if (!uuid.test(expectedObjectId))
|
|
19
19
|
throw new Error('The Microsoft account object id is missing. Sign in to Skillshare in the browser, then run skillshare teams login again.');
|
|
20
20
|
const stores = state.origins.filter(origin => origins.has(origin.origin));
|
|
@@ -91,7 +91,8 @@ export function extractTeamsSession(state, expectedObjectId, now = Date.now(), a
|
|
|
91
91
|
/^\.?(teams\.microsoft\.com|teams\.cloud\.microsoft)$/.test(cookie.domain)) && (allowExpired || Math.min(claims.exp * 1000, cookie.expires * 1000) > now + 30_000);
|
|
92
92
|
})
|
|
93
93
|
.sort((a, b) => b.expires - a.expires)[0];
|
|
94
|
-
|
|
94
|
+
// Teams web no longer always sets skypetoken_asm; the capture then exchanges the Spaces token for one.
|
|
95
|
+
if (!skype && !allowExpired && !skypeOptional)
|
|
95
96
|
return null;
|
|
96
97
|
if (skype)
|
|
97
98
|
tokens.skype = { value: skype.value, expiresAt: new Date(decodeTeamsJwt(skype.value).exp * 1000).toISOString() };
|
|
@@ -151,7 +152,11 @@ export async function captureTeamsLogin(options) {
|
|
|
151
152
|
await abortable(page.goto('https://teams.microsoft.com/v2/', { waitUntil: 'domcontentloaded', timeout: 60_000 }), signal);
|
|
152
153
|
let lastProgress = Date.now();
|
|
153
154
|
let lastRefresh = 0;
|
|
155
|
+
let lastAttemptFresh = false;
|
|
154
156
|
let resetCache = false;
|
|
157
|
+
let lastFailure = '';
|
|
158
|
+
// Exchange through the Teams tab so the browser's network, proxy and certificate settings apply, as they do for Teams itself.
|
|
159
|
+
const exchangeSkype = (spacesToken) => browserSkypeExchange(page, spacesToken);
|
|
155
160
|
while (true) {
|
|
156
161
|
signal.throwIfAborted();
|
|
157
162
|
// Read the current Teams tab only. storageState visits every cached origin and can hang
|
|
@@ -170,18 +175,25 @@ export async function captureTeamsLogin(options) {
|
|
|
170
175
|
throw error;
|
|
171
176
|
}
|
|
172
177
|
const state = { origins: [local], cookies: await abortable(context.cookies(), signal) };
|
|
173
|
-
const session = extractTeamsSession(state, options.objectId);
|
|
174
|
-
if (session && !options.recover)
|
|
178
|
+
const session = extractTeamsSession(state, options.objectId, Date.now(), false, true);
|
|
179
|
+
if (session?.tokens.skype && !options.recover)
|
|
175
180
|
return session;
|
|
176
|
-
|
|
181
|
+
// Retry at once when Teams has just replaced stale cached tokens with fresh ones.
|
|
182
|
+
if (origins.has(new URL(page.url()).origin) && (Date.now() - lastRefresh > 30_000 || session && !lastAttemptFresh)) {
|
|
177
183
|
const cached = session ?? extractTeamsSession(state, options.objectId, Date.now(), true);
|
|
178
184
|
if (cached?.refreshToken) {
|
|
179
185
|
lastRefresh = Date.now();
|
|
186
|
+
lastAttemptFresh = !!session;
|
|
180
187
|
try {
|
|
181
|
-
return await abortable(refreshCapturedSession(cached, fetch, options.recover ?? false, signal), signal);
|
|
188
|
+
return await abortable(refreshCapturedSession(cached, fetch, options.recover ?? false, signal, exchangeSkype), signal);
|
|
182
189
|
}
|
|
183
|
-
catch {
|
|
190
|
+
catch (error) {
|
|
184
191
|
signal.throwIfAborted();
|
|
192
|
+
const failure = describeFailure(error);
|
|
193
|
+
if (failure !== lastFailure) {
|
|
194
|
+
lastFailure = failure;
|
|
195
|
+
options.onProgress?.(`Teams sign-in found, but the Teams API tokens could not be completed yet: ${failure} Retrying every 30 seconds.`);
|
|
196
|
+
}
|
|
185
197
|
if (options.recover && !resetCache) {
|
|
186
198
|
resetCache = true;
|
|
187
199
|
// Expired grants can coexist with valid access tokens. Remove only this account's MSAL
|
|
@@ -223,7 +235,7 @@ function abortable(operation, signal) {
|
|
|
223
235
|
});
|
|
224
236
|
}
|
|
225
237
|
/** The Teams web SPA may not request a search token until search is opened. Reuse its MSAL grant instead. */
|
|
226
|
-
export async function refreshCapturedSession(session, request = fetch, force = false, signal) {
|
|
238
|
+
export async function refreshCapturedSession(session, request = fetch, force = false, signal, exchangeSkype) {
|
|
227
239
|
if (!session.refreshToken)
|
|
228
240
|
throw new Error('A Teams refresh token is required to renew this session.');
|
|
229
241
|
const scopes = {
|
|
@@ -255,22 +267,79 @@ export async function refreshCapturedSession(session, request = fetch, force = f
|
|
|
255
267
|
session.refreshToken = data.refresh_token ?? session.refreshToken;
|
|
256
268
|
}
|
|
257
269
|
if (!session.tokens.skype || new Date(session.tokens.skype.expiresAt).getTime() <= Date.now() + 120_000) {
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
270
|
+
const spaces = session.tokens.spaces.value;
|
|
271
|
+
let skypeToken;
|
|
272
|
+
if (!exchangeSkype)
|
|
273
|
+
skypeToken = await fetchSkypeToken(spaces, request, signal);
|
|
274
|
+
else {
|
|
275
|
+
try {
|
|
276
|
+
skypeToken = await exchangeSkype(spaces);
|
|
277
|
+
}
|
|
278
|
+
catch (browserError) {
|
|
279
|
+
signal?.throwIfAborted();
|
|
280
|
+
try {
|
|
281
|
+
skypeToken = await fetchSkypeToken(spaces, request, signal);
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
throw new Error(`${describeFailure(browserError)} Direct request: ${describeFailure(error)}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const claims = decodeTeamsJwt(skypeToken);
|
|
268
289
|
if (claims?.skypeid?.replace(/^8:/, '').toLowerCase() !== `orgid:${session.objectId.toLowerCase()}` || claims.tid !== session.tenantId || !claims.exp)
|
|
269
290
|
throw new Error('The renewed Skype token belongs to a different account.');
|
|
270
|
-
session.tokens.skype = { value:
|
|
291
|
+
session.tokens.skype = { value: skypeToken, expiresAt: new Date(claims.exp * 1000).toISOString() };
|
|
271
292
|
}
|
|
272
293
|
return session;
|
|
273
294
|
}
|
|
295
|
+
async function fetchSkypeToken(spacesToken, request, signal) {
|
|
296
|
+
const response = await request('https://authsvc.teams.microsoft.com/v1.0/authz', {
|
|
297
|
+
method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${spacesToken}` },
|
|
298
|
+
body: '{}', signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(15_000)]) : AbortSignal.timeout(15_000), redirect: 'error',
|
|
299
|
+
});
|
|
300
|
+
if (!response.ok)
|
|
301
|
+
throw new Error(`Teams could not renew the Skype token (HTTP ${response.status}).`);
|
|
302
|
+
const data = await response.json();
|
|
303
|
+
if (typeof data.tokens?.skypeToken !== 'string')
|
|
304
|
+
throw new Error('Teams returned no Skype token.');
|
|
305
|
+
return data.tokens.skypeToken;
|
|
306
|
+
}
|
|
307
|
+
/** Teams web may no longer request a Skype token itself; ask its auth service from the signed-in Teams tab. */
|
|
308
|
+
async function browserSkypeExchange(page, spacesToken) {
|
|
309
|
+
if (!origins.has(new URL(page.url()).origin))
|
|
310
|
+
throw new Error('The Teams tab is not open.');
|
|
311
|
+
const result = await page.evaluate(async (token) => {
|
|
312
|
+
const failures = [];
|
|
313
|
+
for (const url of [`${location.origin}/api/authsvc/v1.0/authz`, 'https://authsvc.teams.microsoft.com/v1.0/authz']) {
|
|
314
|
+
try {
|
|
315
|
+
const response = await fetch(url, { method: 'POST', credentials: 'omit', redirect: 'error', signal: AbortSignal.timeout(15_000),
|
|
316
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }, body: '{}' });
|
|
317
|
+
if (!response.ok) {
|
|
318
|
+
failures.push(`HTTP ${response.status}`);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
const data = await response.json();
|
|
322
|
+
if (typeof data.tokens?.skypeToken === 'string')
|
|
323
|
+
return { token: data.tokens.skypeToken, failures };
|
|
324
|
+
failures.push('no Skype token');
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
failures.push(error instanceof Error ? error.name : 'request failed');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return { token: '', failures };
|
|
331
|
+
}, spacesToken);
|
|
332
|
+
if (result.token)
|
|
333
|
+
return result.token;
|
|
334
|
+
throw new Error(`The Teams tab could not obtain a Skype token (${result.failures?.join(', ') || 'unknown'}).`);
|
|
335
|
+
}
|
|
336
|
+
/** Error text for progress output; includes network causes such as certificate errors, never request data. */
|
|
337
|
+
export function describeFailure(error) {
|
|
338
|
+
if (!(error instanceof Error))
|
|
339
|
+
return 'Unknown error.';
|
|
340
|
+
const cause = error.cause instanceof Error && error.cause.message && !error.message.includes(error.cause.message) ? ` (${error.cause.message})` : '';
|
|
341
|
+
return `${error.message}${cause}`.slice(0, 400);
|
|
342
|
+
}
|
|
274
343
|
async function resetTeamsGrant(page, objectId, clientId) {
|
|
275
344
|
if (!origins.has(new URL(page.url()).origin))
|
|
276
345
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quadient/skillshare",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.1",
|
|
4
4
|
"description": "Skillshare CLI for installing and publishing Quadient skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"build": "rm -rf dist && tsc -p tsconfig.build.json && node -e \"require('node:fs').copyFileSync('page-browser-client.js', 'dist/page-browser-client.js')\"",
|
|
17
17
|
"start": "node ./dist/index.js",
|
|
18
18
|
"prepublishOnly": "npm run build",
|
|
19
|
-
"test": "tsx --test session-auth.test.ts cli-args.test.ts install-files.test.ts removed-skills.test.ts output.test.ts pages.test.ts page-links.test.ts pages-secrets.test.ts pages-comments.test.ts news.test.ts pages-dev.test.ts teams-auth.test.ts teams-watch.test.ts teams-browser.test.ts salesforce.test.ts agents.test.ts agents-detection.test.ts agents-process.test.ts agents-probe.test.ts agents-lockdown.test.ts agents-approvals.test.ts agents-native-forms.test.ts agents-delivery.test.ts agents-request-upload.test.ts agents-update.test.ts login-callback.test.ts"
|
|
19
|
+
"test": "tsx --test session-auth.test.ts cli-args.test.ts install-files.test.ts removed-skills.test.ts output.test.ts pages.test.ts page-links.test.ts pages-secrets.test.ts pages-runtime.test.ts pages-comments.test.ts news.test.ts pages-dev.test.ts teams-auth.test.ts teams-watch.test.ts teams-browser.test.ts salesforce.test.ts agents.test.ts agents-detection.test.ts agents-process.test.ts agents-probe.test.ts agents-lockdown.test.ts agents-approvals.test.ts agents-native-forms.test.ts agents-delivery.test.ts agents-request-upload.test.ts agents-update.test.ts login-callback.test.ts"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|