@anuma/sdk 11.3.0 → 11.3.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.
@@ -37238,30 +37238,60 @@ async function authenticateICloud() {
37238
37238
  ensureAuthElements();
37239
37239
  return container.setUpAuth();
37240
37240
  }
37241
- async function requestICloudSignIn() {
37242
- const container = await getContainer();
37243
- const { signIn } = ensureAuthElements();
37244
- const existingUser = await container.setUpAuth();
37245
- if (existingUser) {
37246
- return existingUser;
37247
- }
37248
- getLogger().debug("[CloudKit] Sign-in container innerHTML:", signIn.innerHTML);
37249
- getLogger().debug("[CloudKit] Sign-in container children:", signIn.children.length);
37250
- const appleButton = signIn.querySelector(
37251
- "a, button, [role='button'], div[id*='apple']"
37252
- );
37253
- getLogger().debug("[CloudKit] Found button element:", appleButton);
37254
- if (appleButton) {
37255
- getLogger().debug("[CloudKit] Clicking button...");
37256
- appleButton.click();
37257
- } else {
37258
- const anyClickable = signIn.firstElementChild;
37259
- if (anyClickable) {
37260
- getLogger().debug("[CloudKit] Clicking first child element:", anyClickable);
37261
- anyClickable.click();
37241
+ async function requestICloudSignIn({
37242
+ signal
37243
+ } = {}) {
37244
+ if (signal?.aborted) {
37245
+ throw new Error("Sign-in was cancelled");
37246
+ }
37247
+ let cancellationError;
37248
+ let timer;
37249
+ let onAbort;
37250
+ const cancellation = new Promise((_resolve, reject) => {
37251
+ const cancel = (error) => {
37252
+ cancellationError = error;
37253
+ reject(error);
37254
+ };
37255
+ onAbort = () => cancel(new Error("Sign-in was cancelled"));
37256
+ signal?.addEventListener("abort", onAbort, { once: true });
37257
+ timer = setTimeout(() => cancel(new Error("iCloud sign-in timed out")), 6e4);
37258
+ });
37259
+ const throwIfCancelled = () => {
37260
+ if (cancellationError) throw cancellationError;
37261
+ };
37262
+ const signInRequest = async () => {
37263
+ const container = await getContainer();
37264
+ throwIfCancelled();
37265
+ const { signIn } = ensureAuthElements();
37266
+ const existingUser = await container.setUpAuth();
37267
+ throwIfCancelled();
37268
+ if (existingUser) {
37269
+ return existingUser;
37270
+ }
37271
+ getLogger().debug("[CloudKit] Sign-in container innerHTML:", signIn.innerHTML);
37272
+ getLogger().debug("[CloudKit] Sign-in container children:", signIn.children.length);
37273
+ const appleButton = signIn.querySelector(
37274
+ "a, button, [role='button'], div[id*='apple']"
37275
+ );
37276
+ getLogger().debug("[CloudKit] Found button element:", appleButton);
37277
+ if (appleButton) {
37278
+ getLogger().debug("[CloudKit] Clicking button...");
37279
+ appleButton.click();
37280
+ } else {
37281
+ const anyClickable = signIn.firstElementChild;
37282
+ if (anyClickable) {
37283
+ getLogger().debug("[CloudKit] Clicking first child element:", anyClickable);
37284
+ anyClickable.click();
37285
+ }
37262
37286
  }
37287
+ return container.whenUserSignsIn();
37288
+ };
37289
+ try {
37290
+ return await Promise.race([signInRequest(), cancellation]);
37291
+ } finally {
37292
+ clearTimeout(timer);
37293
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
37263
37294
  }
37264
- return container.whenUserSignsIn();
37265
37295
  }
37266
37296
  async function uploadFileToICloud(filename, content, backupRevision) {
37267
37297
  const container = await getContainer();
@@ -35291,30 +35291,60 @@ async function authenticateICloud() {
35291
35291
  ensureAuthElements();
35292
35292
  return container.setUpAuth();
35293
35293
  }
35294
- async function requestICloudSignIn() {
35295
- const container = await getContainer();
35296
- const { signIn } = ensureAuthElements();
35297
- const existingUser = await container.setUpAuth();
35298
- if (existingUser) {
35299
- return existingUser;
35300
- }
35301
- getLogger().debug("[CloudKit] Sign-in container innerHTML:", signIn.innerHTML);
35302
- getLogger().debug("[CloudKit] Sign-in container children:", signIn.children.length);
35303
- const appleButton = signIn.querySelector(
35304
- "a, button, [role='button'], div[id*='apple']"
35305
- );
35306
- getLogger().debug("[CloudKit] Found button element:", appleButton);
35307
- if (appleButton) {
35308
- getLogger().debug("[CloudKit] Clicking button...");
35309
- appleButton.click();
35310
- } else {
35311
- const anyClickable = signIn.firstElementChild;
35312
- if (anyClickable) {
35313
- getLogger().debug("[CloudKit] Clicking first child element:", anyClickable);
35314
- anyClickable.click();
35294
+ async function requestICloudSignIn({
35295
+ signal
35296
+ } = {}) {
35297
+ if (signal?.aborted) {
35298
+ throw new Error("Sign-in was cancelled");
35299
+ }
35300
+ let cancellationError;
35301
+ let timer;
35302
+ let onAbort;
35303
+ const cancellation = new Promise((_resolve, reject) => {
35304
+ const cancel = (error) => {
35305
+ cancellationError = error;
35306
+ reject(error);
35307
+ };
35308
+ onAbort = () => cancel(new Error("Sign-in was cancelled"));
35309
+ signal?.addEventListener("abort", onAbort, { once: true });
35310
+ timer = setTimeout(() => cancel(new Error("iCloud sign-in timed out")), 6e4);
35311
+ });
35312
+ const throwIfCancelled = () => {
35313
+ if (cancellationError) throw cancellationError;
35314
+ };
35315
+ const signInRequest = async () => {
35316
+ const container = await getContainer();
35317
+ throwIfCancelled();
35318
+ const { signIn } = ensureAuthElements();
35319
+ const existingUser = await container.setUpAuth();
35320
+ throwIfCancelled();
35321
+ if (existingUser) {
35322
+ return existingUser;
35323
+ }
35324
+ getLogger().debug("[CloudKit] Sign-in container innerHTML:", signIn.innerHTML);
35325
+ getLogger().debug("[CloudKit] Sign-in container children:", signIn.children.length);
35326
+ const appleButton = signIn.querySelector(
35327
+ "a, button, [role='button'], div[id*='apple']"
35328
+ );
35329
+ getLogger().debug("[CloudKit] Found button element:", appleButton);
35330
+ if (appleButton) {
35331
+ getLogger().debug("[CloudKit] Clicking button...");
35332
+ appleButton.click();
35333
+ } else {
35334
+ const anyClickable = signIn.firstElementChild;
35335
+ if (anyClickable) {
35336
+ getLogger().debug("[CloudKit] Clicking first child element:", anyClickable);
35337
+ anyClickable.click();
35338
+ }
35315
35339
  }
35340
+ return container.whenUserSignsIn();
35341
+ };
35342
+ try {
35343
+ return await Promise.race([signInRequest(), cancellation]);
35344
+ } finally {
35345
+ clearTimeout(timer);
35346
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
35316
35347
  }
35317
- return container.whenUserSignsIn();
35318
35348
  }
35319
35349
  async function uploadFileToICloud(filename, content, backupRevision) {
35320
35350
  const container = await getContainer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "11.3.0",
3
+ "version": "11.3.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",