@quadient/skillshare 1.20.1 → 1.20.3
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/help.js +1 -1
- package/dist/index.js +2 -1
- package/dist/pages-comments.js +2 -2
- package/dist/pages-secrets.js +1 -1
- package/dist/teams-auth.js +39 -0
- package/package.json +1 -1
package/dist/help.js
CHANGED
|
@@ -99,7 +99,7 @@ export const COMMANDS = [
|
|
|
99
99
|
'pages dev [directory] [--slug <slug>] [--port <port>] [--build <command> --watch-dir <sources>]',
|
|
100
100
|
' [--celld <executable>] [--user-id <id>] [--user-name <name>] [--user-email <email>]',
|
|
101
101
|
],
|
|
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
|
+
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 their co-owner or 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.',
|
|
103
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"'],
|
|
104
104
|
flags: ['slug', 'path', 'author', 'resolved', 'external', 'internal', 'min', 'max', 'always-on', 'json'],
|
|
105
105
|
},
|
package/dist/index.js
CHANGED
|
@@ -1437,7 +1437,8 @@ async function describePageUploadTarget(client, slug) {
|
|
|
1437
1437
|
throw error;
|
|
1438
1438
|
}
|
|
1439
1439
|
const me = await client.get('/api/auth/me');
|
|
1440
|
-
const isOwner = me.storedUserId != null && me.storedUserId === page.ownerUserId
|
|
1440
|
+
const isOwner = me.storedUserId != null && (me.storedUserId === page.ownerUserId
|
|
1441
|
+
|| (page.coOwners ?? []).some((owner) => owner.userId === me.storedUserId));
|
|
1441
1442
|
if (!isOwner && !me.isAdmin) {
|
|
1442
1443
|
throw new Error(`Page /p/${slug}/ belongs to ${page.ownerDisplayName}. Choose another --slug.`);
|
|
1443
1444
|
}
|
package/dist/pages-comments.js
CHANGED
|
@@ -131,8 +131,8 @@ async function expectJson(slug, response, id) {
|
|
|
131
131
|
return await response.json();
|
|
132
132
|
if (response.status === 403) {
|
|
133
133
|
throw new Error(id
|
|
134
|
-
? `Only the comment's author,
|
|
135
|
-
: `Only
|
|
134
|
+
? `Only the comment's author, an owner of /p/${slug}/ or an administrator can change #${id}.`
|
|
135
|
+
: `Only an owner of /p/${slug}/ or an administrator can change its annotation settings.`);
|
|
136
136
|
}
|
|
137
137
|
if (response.status === 404)
|
|
138
138
|
throw new Error(id ? `Comment #${id} on /p/${slug}/ was not found.` : `Page /p/${slug}/ was not found.`);
|
package/dist/pages-secrets.js
CHANGED
|
@@ -50,7 +50,7 @@ async function expectSecrets(slug, response, name) {
|
|
|
50
50
|
if (response.ok)
|
|
51
51
|
return await response.json();
|
|
52
52
|
if (response.status === 403)
|
|
53
|
-
throw new Error(`Only the owner of /p/${slug}/ or an administrator can manage its secrets.`);
|
|
53
|
+
throw new Error(`Only the owner or a co-owner of /p/${slug}/ or an administrator can manage its secrets.`);
|
|
54
54
|
if (response.status === 404) {
|
|
55
55
|
throw new Error(name ? `Page /p/${slug}/ or its secret ${name} was not found.` : `Page /p/${slug}/ was not found.`);
|
|
56
56
|
}
|
package/dist/teams-auth.js
CHANGED
|
@@ -155,6 +155,9 @@ export async function captureTeamsLogin(options) {
|
|
|
155
155
|
let lastAttemptFresh = false;
|
|
156
156
|
let resetCache = false;
|
|
157
157
|
let lastFailure = '';
|
|
158
|
+
let teamsOpenSince = null;
|
|
159
|
+
let stallRecovery = 'none';
|
|
160
|
+
const stallMs = options.stallMs ?? 60_000;
|
|
158
161
|
// Exchange through the Teams tab so the browser's network, proxy and certificate settings apply, as they do for Teams itself.
|
|
159
162
|
const exchangeSkype = (spacesToken) => browserSkypeExchange(page, spacesToken);
|
|
160
163
|
while (true) {
|
|
@@ -206,6 +209,27 @@ export async function captureTeamsLogin(options) {
|
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
211
|
}
|
|
212
|
+
// Time only while Teams itself is open; a Microsoft sign-in page means the user is still signing in.
|
|
213
|
+
teamsOpenSince = origins.has(new URL(page.url()).origin) ? teamsOpenSince ?? Date.now() : null;
|
|
214
|
+
if (!options.recover && teamsOpenSince !== null && Date.now() - teamsOpenSince > stallMs) {
|
|
215
|
+
if (stallRecovery === 'none') {
|
|
216
|
+
stallRecovery = 'reset';
|
|
217
|
+
options.onProgress?.('Teams has provided no API tokens for a minute. Clearing Teams web data in the Skillshare browser profile ' +
|
|
218
|
+
'(Microsoft sign-in cookies are kept) and reloading Teams.');
|
|
219
|
+
await abortable(clearTeamsWebData(page), signal);
|
|
220
|
+
await abortable(page.goto('https://teams.microsoft.com/v2/', { waitUntil: 'domcontentloaded', timeout: 60_000 }), signal);
|
|
221
|
+
teamsOpenSince = null;
|
|
222
|
+
lastRefresh = 0;
|
|
223
|
+
lastAttemptFresh = false;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (stallRecovery === 'reset') {
|
|
227
|
+
stallRecovery = 'hinted';
|
|
228
|
+
options.onProgress?.('Teams still provides no API tokens. Press Ctrl+C, move the Skillshare browser profile aside and run skillshare teams login again; ' +
|
|
229
|
+
`you will sign in to Microsoft once more:\n mv ${JSON.stringify(options.profileDirectory)} ${JSON.stringify(options.profileDirectory + '.bak')}`);
|
|
230
|
+
lastProgress = Date.now();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
209
233
|
if (Date.now() - lastProgress > 30_000) {
|
|
210
234
|
options.onProgress?.('Waiting for Teams sign-in and API tokens. Finish sign-in in the browser; open Teams search if needed.');
|
|
211
235
|
lastProgress = Date.now();
|
|
@@ -340,6 +364,21 @@ export function describeFailure(error) {
|
|
|
340
364
|
const cause = error.cause instanceof Error && error.cause.message && !error.message.includes(error.cause.message) ? ` (${error.cause.message})` : '';
|
|
341
365
|
return `${error.message}${cause}`.slice(0, 400);
|
|
342
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Teams web can stall on stale cached app data ("Almost there…", "There was a problem reaching this app"). Clear what Teams
|
|
369
|
+
* stores per origin in this dedicated profile, but keep cookies so Microsoft SSO signs Teams in again without a prompt.
|
|
370
|
+
*/
|
|
371
|
+
export async function clearTeamsWebData(page) {
|
|
372
|
+
const session = await page.context().newCDPSession(page);
|
|
373
|
+
try {
|
|
374
|
+
for (const origin of origins)
|
|
375
|
+
await session.send('Storage.clearDataForOrigin', { origin,
|
|
376
|
+
storageTypes: 'local_storage,indexeddb,service_workers,cache_storage,file_systems,websql,shader_cache' });
|
|
377
|
+
}
|
|
378
|
+
finally {
|
|
379
|
+
await session.detach().catch(() => { });
|
|
380
|
+
}
|
|
381
|
+
}
|
|
343
382
|
async function resetTeamsGrant(page, objectId, clientId) {
|
|
344
383
|
if (!origins.has(new URL(page.url()).origin))
|
|
345
384
|
return;
|