appwrite-cli 22.1.2 → 22.2.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/dist/index.js CHANGED
@@ -24340,7 +24340,7 @@ var require_sbcs = __commonJS({
24340
24340
  return mod && mod.__esModule ? mod : { "default": mod };
24341
24341
  };
24342
24342
  Object.defineProperty(exports, "__esModule", { value: true });
24343
- exports.KOI8_R = exports.windows_1256 = exports.windows_1251 = exports.ISO_8859_9 = exports.ISO_8859_8 = exports.ISO_8859_7 = exports.ISO_8859_6 = exports.ISO_8859_5 = exports.ISO_8859_2 = exports.ISO_8859_1 = void 0;
24343
+ exports.KOI8_R = exports.windows_874 = exports.windows_1258 = exports.windows_1257 = exports.windows_1256 = exports.windows_1251 = exports.ISO_8859_9 = exports.ISO_8859_8 = exports.ISO_8859_7 = exports.ISO_8859_6 = exports.ISO_8859_5 = exports.ISO_8859_2 = exports.ISO_8859_1 = void 0;
24344
24344
  var match_1 = __importDefault(require_match());
24345
24345
  var N_GRAM_MASK = 16777215;
24346
24346
  var NGramParser = class {
@@ -28343,6 +28343,443 @@ var require_sbcs = __commonJS({
28343
28343
  }
28344
28344
  };
28345
28345
  exports.windows_1256 = windows_1256;
28346
+ var windows_1257 = class extends sbcs {
28347
+ match(det) {
28348
+ return det.inputBytes.some((byte) => byte >= 128) ? super.match(det) : null;
28349
+ }
28350
+ byteMap() {
28351
+ const byteMap = new Array(256).fill(32);
28352
+ byteMap[39] = 0;
28353
+ for (let i = 65; i <= 90; i++)
28354
+ byteMap[i] = i + 32;
28355
+ for (let i = 97; i <= 122; i++)
28356
+ byteMap[i] = i;
28357
+ byteMap[142] = 142;
28358
+ byteMap[168] = byteMap[184] = 184;
28359
+ byteMap[170] = byteMap[186] = 186;
28360
+ byteMap[175] = byteMap[191] = 191;
28361
+ byteMap[181] = 181;
28362
+ for (let i = 192; i <= 214; i++)
28363
+ byteMap[i] = i + 32;
28364
+ for (let i = 216; i <= 222; i++)
28365
+ byteMap[i] = i + 32;
28366
+ byteMap[223] = 223;
28367
+ for (let i = 224; i <= 246; i++)
28368
+ byteMap[i] = i;
28369
+ for (let i = 248; i <= 254; i++)
28370
+ byteMap[i] = i;
28371
+ return byteMap;
28372
+ }
28373
+ ngrams() {
28374
+ return [
28375
+ new NGramsPlusLang("et", [
28376
+ 2122090,
28377
+ 2122098,
28378
+ 2123109,
28379
+ 2124135,
28380
+ 2124385,
28381
+ 2124641,
28382
+ 2124645,
28383
+ 2124649,
28384
+ 2124655,
28385
+ 2124661,
28386
+ 2124897,
28387
+ 2125417,
28388
+ 2125678,
28389
+ 2126441,
28390
+ 2126693,
28391
+ 2126949,
28392
+ 6365281,
28393
+ 6365290,
28394
+ 6365291,
28395
+ 6365292,
28396
+ 6382112,
28397
+ 6382624,
28398
+ 6384499,
28399
+ 6386549,
28400
+ 6386785,
28401
+ 6387297,
28402
+ 6561908,
28403
+ 6578464,
28404
+ 6583667,
28405
+ 6627435,
28406
+ 6627443,
28407
+ 6645100,
28408
+ 6645107,
28409
+ 6646816,
28410
+ 6646885,
28411
+ 6646900,
28412
+ 6648608,
28413
+ 6648692,
28414
+ 6889579,
28415
+ 6906912,
28416
+ 6910570,
28417
+ 6910752,
28418
+ 6971680,
28419
+ 7037299,
28420
+ 7038309,
28421
+ 7039346,
28422
+ 7040879,
28423
+ 7041893,
28424
+ 7041908,
28425
+ 7104875,
28426
+ 7107616,
28427
+ 7544929,
28428
+ 7544939,
28429
+ 7562528,
28430
+ 7562604,
28431
+ 7566437,
28432
+ 7566441,
28433
+ 7566708,
28434
+ 7627115,
28435
+ 7627124,
28436
+ 7629088,
28437
+ 7697184,
28438
+ 7697253,
28439
+ 7697505
28440
+ ]),
28441
+ new NGramsPlusLang("lv", [
28442
+ 2122098,
28443
+ 2122601,
28444
+ 2122849,
28445
+ 2124146,
28446
+ 2124154,
28447
+ 2124897,
28448
+ 2125282,
28449
+ 2125921,
28450
+ 2125938,
28451
+ 2126433,
28452
+ 2126689,
28453
+ 2126699,
28454
+ 2126949,
28455
+ 2127214,
28456
+ 2127457,
28457
+ 6365289,
28458
+ 6365301,
28459
+ 6365302,
28460
+ 6382185,
28461
+ 6383904,
28462
+ 6384499,
28463
+ 6384751,
28464
+ 6385778,
28465
+ 6386293,
28466
+ 6386464,
28467
+ 6386806,
28468
+ 6449509,
28469
+ 6452512,
28470
+ 6515052,
28471
+ 6515060,
28472
+ 6578464,
28473
+ 6578546,
28474
+ 6583584,
28475
+ 6584864,
28476
+ 6644850,
28477
+ 6646123,
28478
+ 6646643,
28479
+ 6647393,
28480
+ 6648608,
28481
+ 6680693,
28482
+ 6889577,
28483
+ 6907236,
28484
+ 6907376,
28485
+ 6908642,
28486
+ 6909046,
28487
+ 7041908,
28488
+ 7102836,
28489
+ 7106404,
28490
+ 7233824,
28491
+ 7300193,
28492
+ 7496043,
28493
+ 7501166,
28494
+ 7544947,
28495
+ 7544949,
28496
+ 7544950,
28497
+ 7566453,
28498
+ 7566574,
28499
+ 7632160,
28500
+ 7632489,
28501
+ 7676022,
28502
+ 7695904,
28503
+ 7697184,
28504
+ 7758188,
28505
+ 14840608
28506
+ ]),
28507
+ new NGramsPlusLang("lt", [
28508
+ 2122089,
28509
+ 2122341,
28510
+ 2124146,
28511
+ 2124641,
28512
+ 2124905,
28513
+ 2125167,
28514
+ 2126433,
28515
+ 2126689,
28516
+ 2126699,
28517
+ 2126709,
28518
+ 2126945,
28519
+ 2126949,
28520
+ 2126965,
28521
+ 2127457,
28522
+ 2127465,
28523
+ 6365300,
28524
+ 6365424,
28525
+ 6383904,
28526
+ 6383988,
28527
+ 6384112,
28528
+ 6384738,
28529
+ 6384993,
28530
+ 6385268,
28531
+ 6386274,
28532
+ 6386292,
28533
+ 6386976,
28534
+ 6387050,
28535
+ 6418553,
28536
+ 6447392,
28537
+ 6448489,
28538
+ 6448494,
28539
+ 6647401,
28540
+ 6648949,
28541
+ 6889569,
28542
+ 6889577,
28543
+ 6889579,
28544
+ 6889581,
28545
+ 6906217,
28546
+ 6907246,
28547
+ 6907252,
28548
+ 6909543,
28549
+ 6910496,
28550
+ 6910752,
28551
+ 6942827,
28552
+ 6971757,
28553
+ 6972704,
28554
+ 7037289,
28555
+ 7037292,
28556
+ 7103073,
28557
+ 7104869,
28558
+ 7170419,
28559
+ 7171947,
28560
+ 7269152,
28561
+ 7301733,
28562
+ 7302009,
28563
+ 7303968,
28564
+ 7496176,
28565
+ 7544937,
28566
+ 7544939,
28567
+ 7544950,
28568
+ 7564129,
28569
+ 7629088,
28570
+ 7632246,
28571
+ 7957356
28572
+ ])
28573
+ ];
28574
+ }
28575
+ name() {
28576
+ return "windows-1257";
28577
+ }
28578
+ };
28579
+ exports.windows_1257 = windows_1257;
28580
+ var windows_1258 = class extends sbcs {
28581
+ match(det) {
28582
+ return det.inputBytes.some((byte) => byte >= 128) ? super.match(det) : null;
28583
+ }
28584
+ byteMap() {
28585
+ const byteMap = new Array(256).fill(32);
28586
+ byteMap[39] = 0;
28587
+ for (let i = 65; i <= 90; i++)
28588
+ byteMap[i] = i + 32;
28589
+ for (let i = 97; i <= 122; i++)
28590
+ byteMap[i] = i;
28591
+ byteMap[131] = 131;
28592
+ byteMap[136] = 136;
28593
+ byteMap[140] = byteMap[156] = 156;
28594
+ byteMap[159] = 255;
28595
+ byteMap[170] = 170;
28596
+ byteMap[181] = 181;
28597
+ byteMap[186] = 186;
28598
+ for (let i = 192; i <= 203; i++)
28599
+ byteMap[i] = i + 32;
28600
+ byteMap[204] = 204;
28601
+ for (let i = 205; i <= 209; i++)
28602
+ byteMap[i] = i + 32;
28603
+ byteMap[210] = 210;
28604
+ for (let i = 211; i <= 214; i++)
28605
+ byteMap[i] = i + 32;
28606
+ for (let i = 216; i <= 221; i++)
28607
+ byteMap[i] = i + 32;
28608
+ byteMap[222] = 222;
28609
+ byteMap[223] = 223;
28610
+ for (let i = 224; i <= 246; i++)
28611
+ byteMap[i] = i;
28612
+ for (let i = 248; i <= 253; i++)
28613
+ byteMap[i] = i;
28614
+ byteMap[255] = 255;
28615
+ return byteMap;
28616
+ }
28617
+ ngrams() {
28618
+ return [
28619
+ 2122600,
28620
+ 2122721,
28621
+ 2123625,
28622
+ 2123887,
28623
+ 2125415,
28624
+ 2125928,
28625
+ 2126952,
28626
+ 2126953,
28627
+ 2126962,
28628
+ 2127465,
28629
+ 2127584,
28630
+ 6419060,
28631
+ 6496355,
28632
+ 6496374,
28633
+ 6514720,
28634
+ 6514925,
28635
+ 6545763,
28636
+ 6758504,
28637
+ 6758510,
28638
+ 6758516,
28639
+ 6758518,
28640
+ 6812782,
28641
+ 6815198,
28642
+ 6815221,
28643
+ 6824052,
28644
+ 6844402,
28645
+ 6876526,
28646
+ 6889582,
28647
+ 6889588,
28648
+ 6941394,
28649
+ 6941420,
28650
+ 6941426,
28651
+ 7217251,
28652
+ 7217262,
28653
+ 7217268,
28654
+ 7235360,
28655
+ 7235572,
28656
+ 7235581,
28657
+ 7235616,
28658
+ 7302759,
28659
+ 7336547,
28660
+ 7610483,
28661
+ 7629053,
28662
+ 7629290,
28663
+ 7631471,
28664
+ 7676020,
28665
+ 7760362,
28666
+ 7790624,
28667
+ 13396256,
28668
+ 13397607,
28669
+ 14557288,
28670
+ 14771048,
28671
+ 15395950,
28672
+ 15397492,
28673
+ 15494759,
28674
+ 15496224,
28675
+ 15560296,
28676
+ 15885088,
28677
+ 15886624,
28678
+ 15887904,
28679
+ 15889440,
28680
+ 16018976,
28681
+ 16108649,
28682
+ 16643532
28683
+ ];
28684
+ }
28685
+ name() {
28686
+ return "windows-1258";
28687
+ }
28688
+ language() {
28689
+ return "vi";
28690
+ }
28691
+ };
28692
+ exports.windows_1258 = windows_1258;
28693
+ var windows_874 = class extends sbcs {
28694
+ byteMap() {
28695
+ const byteMap = new Array(256).fill(32);
28696
+ byteMap[39] = 0;
28697
+ for (let i = 65; i <= 90; i++)
28698
+ byteMap[i] = i + 32;
28699
+ for (let i = 97; i <= 122; i++)
28700
+ byteMap[i] = i;
28701
+ for (let i = 161; i <= 218; i++)
28702
+ byteMap[i] = i;
28703
+ for (let i = 223; i <= 251; i++)
28704
+ byteMap[i] = i;
28705
+ return byteMap;
28706
+ }
28707
+ ngrams() {
28708
+ return [
28709
+ 2138578,
28710
+ 2138856,
28711
+ 2146514,
28712
+ 2148291,
28713
+ 2154949,
28714
+ 10604985,
28715
+ 10605251,
28716
+ 10669479,
28717
+ 10671554,
28718
+ 10799058,
28719
+ 11064263,
28720
+ 11195847,
28721
+ 11200960,
28722
+ 11200995,
28723
+ 11910083,
28724
+ 12042976,
28725
+ 12042979,
28726
+ 12047848,
28727
+ 12132544,
28728
+ 12165586,
28729
+ 12173522,
28730
+ 12305360,
28731
+ 12314553,
28732
+ 12636873,
28733
+ 12828960,
28734
+ 12829619,
28735
+ 12829633,
28736
+ 12832936,
28737
+ 12832994,
28738
+ 12837026,
28739
+ 13091779,
28740
+ 13095353,
28741
+ 13095617,
28742
+ 13096117,
28743
+ 13226679,
28744
+ 13226724,
28745
+ 13293544,
28746
+ 13477063,
28747
+ 13674707,
28748
+ 13689538,
28749
+ 13744416,
28750
+ 13805473,
28751
+ 13812171,
28752
+ 13812452,
28753
+ 13812512,
28754
+ 13812704,
28755
+ 13814226,
28756
+ 13821111,
28757
+ 13879249,
28758
+ 13940155,
28759
+ 14009017,
28760
+ 14010324,
28761
+ 14149837,
28762
+ 14721749,
28763
+ 14728167,
28764
+ 14796240,
28765
+ 14860964,
28766
+ 14920425,
28767
+ 14924193,
28768
+ 14989250,
28769
+ 15258279,
28770
+ 15262634,
28771
+ 15319250,
28772
+ 15328185
28773
+ ];
28774
+ }
28775
+ name() {
28776
+ return "windows-874";
28777
+ }
28778
+ language() {
28779
+ return "th";
28780
+ }
28781
+ };
28782
+ exports.windows_874 = windows_874;
28346
28783
  var KOI8_R = class extends sbcs {
28347
28784
  byteMap() {
28348
28785
  return [
@@ -28894,6 +29331,9 @@ var require_lib = __commonJS({
28894
29331
  new sbcs.ISO_8859_9(),
28895
29332
  new sbcs.windows_1251(),
28896
29333
  new sbcs.windows_1256(),
29334
+ new sbcs.windows_1257(),
29335
+ new sbcs.windows_1258(),
29336
+ new sbcs.windows_874(),
28897
29337
  new sbcs.KOI8_R(),
28898
29338
  new ascii_1.default()
28899
29339
  ];
@@ -65105,7 +65545,7 @@ var id_default = ID;
65105
65545
  // lib/constants.ts
65106
65546
  var SDK_TITLE = "Appwrite";
65107
65547
  var SDK_TITLE_LOWER = "appwrite";
65108
- var SDK_VERSION = "22.1.2";
65548
+ var SDK_VERSION = "22.2.0";
65109
65549
  var SDK_LOGO = "\n _ _ _ ___ __ _____\n /_\\ _ __ _ ____ ___ __(_) |_ ___ / __\\ / / \\_ \\\n //_\\\\| '_ \\| '_ \\ \\ /\\ / / '__| | __/ _ \\ / / / / / /\\/\n / _ \\ |_) | |_) \\ V V /| | | | || __/ / /___/ /___/\\/ /_\n \\_/ \\_/ .__/| .__/ \\_/\\_/ |_| |_|\\__\\___| \\____/\\____/\\____/\n |_| |_|\n\n";
65110
65550
  var EXECUTABLE_NAME = "appwrite";
65111
65551
  var UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
@@ -80332,7 +80772,7 @@ var Client = class _Client {
80332
80772
  "x-sdk-name": "Console",
80333
80773
  "x-sdk-platform": "console",
80334
80774
  "x-sdk-language": "web",
80335
- "x-sdk-version": "15.0.0",
80775
+ "x-sdk-version": "15.1.1",
80336
80776
  "X-Appwrite-Response-Format": "1.9.5"
80337
80777
  };
80338
80778
  this.realtime = {
@@ -85273,15 +85713,21 @@ var Functions = class {
85273
85713
  };
85274
85714
  return this.client.call("get", uri, apiHeaders, payload);
85275
85715
  }
85276
- /**
85277
- * List allowed function specifications for this instance.
85278
- *
85279
- * @throws {AppwriteException}
85280
- * @returns {Promise<Models.SpecificationList>}
85281
- */
85282
- listSpecifications() {
85716
+ listSpecifications(paramsOrFirst) {
85717
+ let params;
85718
+ if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
85719
+ params = paramsOrFirst || {};
85720
+ } else {
85721
+ params = {
85722
+ type: paramsOrFirst
85723
+ };
85724
+ }
85725
+ const type = params.type;
85283
85726
  const apiPath = "/functions/specifications";
85284
85727
  const payload = {};
85728
+ if (typeof type !== "undefined") {
85729
+ payload["type"] = type;
85730
+ }
85285
85731
  const uri = new URL(this.client.config.endpoint + apiPath);
85286
85732
  const apiHeaders = {
85287
85733
  "X-Appwrite-Project": this.client.config.project,
@@ -89363,7 +89809,8 @@ var Oauth2 = class {
89363
89809
  codeChallengeMethod: rest[6],
89364
89810
  prompt: rest[7],
89365
89811
  maxAge: rest[8],
89366
- authorizationDetails: rest[9]
89812
+ authorizationDetails: rest[9],
89813
+ resource: rest[10]
89367
89814
  };
89368
89815
  }
89369
89816
  const clientId = params.clientId;
@@ -89377,6 +89824,7 @@ var Oauth2 = class {
89377
89824
  const prompt = params.prompt;
89378
89825
  const maxAge = params.maxAge;
89379
89826
  const authorizationDetails = params.authorizationDetails;
89827
+ const resource = params.resource;
89380
89828
  if (typeof clientId === "undefined") {
89381
89829
  throw new AppwriteException('Missing required parameter: "clientId"');
89382
89830
  }
@@ -89424,6 +89872,9 @@ var Oauth2 = class {
89424
89872
  if (typeof authorizationDetails !== "undefined") {
89425
89873
  payload["authorization_details"] = authorizationDetails;
89426
89874
  }
89875
+ if (typeof resource !== "undefined") {
89876
+ payload["resource"] = resource;
89877
+ }
89427
89878
  const uri = new URL(this.client.config.endpoint + apiPath);
89428
89879
  const apiHeaders = {
89429
89880
  "accept": "application/json"
@@ -89438,12 +89889,14 @@ var Oauth2 = class {
89438
89889
  params = {
89439
89890
  clientId: paramsOrFirst,
89440
89891
  scope: rest[0],
89441
- authorizationDetails: rest[1]
89892
+ authorizationDetails: rest[1],
89893
+ resource: rest[2]
89442
89894
  };
89443
89895
  }
89444
89896
  const clientId = params.clientId;
89445
89897
  const scope = params.scope;
89446
89898
  const authorizationDetails = params.authorizationDetails;
89899
+ const resource = params.resource;
89447
89900
  const apiPath = "/oauth2/{project_id}/device_authorization".replace("{project_id}", encodeURIComponent(String(this.client.config.project)));
89448
89901
  const payload = {};
89449
89902
  if (typeof clientId !== "undefined") {
@@ -89455,6 +89908,9 @@ var Oauth2 = class {
89455
89908
  if (typeof authorizationDetails !== "undefined") {
89456
89909
  payload["authorization_details"] = authorizationDetails;
89457
89910
  }
89911
+ if (typeof resource !== "undefined") {
89912
+ payload["resource"] = resource;
89913
+ }
89458
89914
  const uri = new URL(this.client.config.endpoint + apiPath);
89459
89915
  const apiHeaders = {
89460
89916
  "content-type": "application/json",
@@ -89632,7 +90088,8 @@ var Oauth2 = class {
89632
90088
  clientId: rest[3],
89633
90089
  clientSecret: rest[4],
89634
90090
  codeVerifier: rest[5],
89635
- redirectUri: rest[6]
90091
+ redirectUri: rest[6],
90092
+ resource: rest[7]
89636
90093
  };
89637
90094
  }
89638
90095
  const grantType = params.grantType;
@@ -89643,6 +90100,7 @@ var Oauth2 = class {
89643
90100
  const clientSecret = params.clientSecret;
89644
90101
  const codeVerifier = params.codeVerifier;
89645
90102
  const redirectUri = params.redirectUri;
90103
+ const resource = params.resource;
89646
90104
  if (typeof grantType === "undefined") {
89647
90105
  throw new AppwriteException('Missing required parameter: "grantType"');
89648
90106
  }
@@ -89672,6 +90130,9 @@ var Oauth2 = class {
89672
90130
  if (typeof redirectUri !== "undefined") {
89673
90131
  payload["redirect_uri"] = redirectUri;
89674
90132
  }
90133
+ if (typeof resource !== "undefined") {
90134
+ payload["resource"] = resource;
90135
+ }
89675
90136
  const uri = new URL(this.client.config.endpoint + apiPath);
89676
90137
  const apiHeaders = {
89677
90138
  "content-type": "application/json",
@@ -95244,15 +95705,21 @@ var Sites = class {
95244
95705
  };
95245
95706
  return this.client.call("get", uri, apiHeaders, payload);
95246
95707
  }
95247
- /**
95248
- * List allowed site specifications for this instance.
95249
- *
95250
- * @throws {AppwriteException}
95251
- * @returns {Promise<Models.SpecificationList>}
95252
- */
95253
- listSpecifications() {
95708
+ listSpecifications(paramsOrFirst) {
95709
+ let params;
95710
+ if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
95711
+ params = paramsOrFirst || {};
95712
+ } else {
95713
+ params = {
95714
+ type: paramsOrFirst
95715
+ };
95716
+ }
95717
+ const type = params.type;
95254
95718
  const apiPath = "/sites/specifications";
95255
95719
  const payload = {};
95720
+ if (typeof type !== "undefined") {
95721
+ payload["type"] = type;
95722
+ }
95256
95723
  const uri = new URL(this.client.config.endpoint + apiPath);
95257
95724
  const apiHeaders = {
95258
95725
  "X-Appwrite-Project": this.client.config.project,
@@ -104320,6 +104787,9 @@ var Global = class _Global extends Config {
104320
104787
  setCookie(cookie) {
104321
104788
  this.setTo(_Global.PREFERENCE_COOKIE, cookie);
104322
104789
  }
104790
+ removeCookie() {
104791
+ this.deleteFrom(_Global.PREFERENCE_COOKIE);
104792
+ }
104323
104793
  getProject() {
104324
104794
  if (!this.hasFrom(_Global.PREFERENCE_PROJECT)) {
104325
104795
  return "";
@@ -104397,6 +104867,16 @@ var Global = class _Global extends Config {
104397
104867
  this.write();
104398
104868
  }
104399
104869
  }
104870
+ deleteFrom(key) {
104871
+ const current = this.getCurrentSession();
104872
+ if (current) {
104873
+ const config2 = this.get(current);
104874
+ if (config2 && config2[key] !== void 0) {
104875
+ delete config2[key];
104876
+ this.write();
104877
+ }
104878
+ }
104879
+ }
104400
104880
  };
104401
104881
  var localConfig = new Local();
104402
104882
  var globalConfig2 = new Global();
@@ -104411,7 +104891,7 @@ var package_default = {
104411
104891
  type: "module",
104412
104892
  homepage: "https://appwrite.io/support",
104413
104893
  description: "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
104414
- version: "22.1.2",
104894
+ version: "22.2.0",
104415
104895
  license: "BSD-3-Clause",
104416
104896
  main: "dist/index.cjs",
104417
104897
  module: "dist/index.js",
@@ -104443,9 +104923,9 @@ var package_default = {
104443
104923
  "build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
104444
104924
  "build:runtime": "npm run build:lib:runtime && npm run build:cli",
104445
104925
  "build:lib:runtime": "npm run build:lib:esm && npm run build:lib:cjs",
104446
- "build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --external:terminal-image --outfile=dist/index.js",
104447
- "build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:terminal-image --outfile=dist/index.cjs",
104448
- "build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --external:terminal-image --outfile=dist/cli.cjs",
104926
+ "build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --external:@napi-rs/keyring --external:terminal-image --outfile=dist/index.js",
104927
+ "build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:@napi-rs/keyring --external:terminal-image --outfile=dist/index.cjs",
104928
+ "build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:@napi-rs/keyring --external:fsevents --external:terminal-image --outfile=dist/cli.cjs",
104449
104929
  lint: "eslint .",
104450
104930
  format: 'prettier --write "**/*.{js,ts,json,md}"',
104451
104931
  generate: "tsx scripts/generate-commands.ts",
@@ -104459,7 +104939,8 @@ var package_default = {
104459
104939
  "windows-arm64": "bun build cli.ts --compile --minify --target=bun-windows-arm64 --outfile build/appwrite-cli-win-arm64.exe"
104460
104940
  },
104461
104941
  dependencies: {
104462
- "@appwrite.io/console": "^15.0.0",
104942
+ "@appwrite.io/console": "^15.1.1",
104943
+ "@napi-rs/keyring": "^1.3.0",
104463
104944
  chalk: "4.1.2",
104464
104945
  chokidar: "^3.6.0",
104465
104946
  "cli-progress": "^3.12.0",
@@ -109005,14 +109486,74 @@ var import_undici = __toESM(require_undici(), 1);
109005
109486
 
109006
109487
  // lib/sdks.ts
109007
109488
  import os4 from "os";
109489
+
109490
+ // lib/auth/refresh-token.ts
109491
+ import { Entry } from "@napi-rs/keyring";
109492
+ var REFRESH_TOKEN_SERVICE = `${EXECUTABLE_NAME}-oauth-refresh-token`;
109493
+ var keyringEntryFactory = (service, account) => new Entry(service, account);
109494
+ var getSessionData = (sessionId) => globalConfig2.get(sessionId);
109495
+ var setSessionData = (sessionId, data) => {
109496
+ globalConfig2.addSession(sessionId, data);
109497
+ };
109498
+ var setPrefsRefreshToken = (sessionId, refreshToken) => {
109499
+ const session = getSessionData(sessionId);
109500
+ if (!session) return;
109501
+ setSessionData(sessionId, {
109502
+ ...session,
109503
+ refreshToken
109504
+ });
109505
+ };
109506
+ var deletePrefsRefreshToken = (sessionId) => {
109507
+ const session = getSessionData(sessionId);
109508
+ if (!session?.refreshToken) return;
109509
+ const { refreshToken: _refreshToken, ...rest } = session;
109510
+ setSessionData(sessionId, rest);
109511
+ };
109512
+ var getStoredRefreshToken = (sessionId) => {
109513
+ try {
109514
+ const refreshToken = keyringEntryFactory(
109515
+ REFRESH_TOKEN_SERVICE,
109516
+ sessionId
109517
+ ).getPassword();
109518
+ if (refreshToken) {
109519
+ return refreshToken;
109520
+ }
109521
+ } catch (_error) {
109522
+ }
109523
+ return getSessionData(sessionId)?.refreshToken ?? "";
109524
+ };
109525
+ var setStoredRefreshToken = (sessionId, refreshToken) => {
109526
+ if (!refreshToken) {
109527
+ deleteStoredRefreshToken(sessionId);
109528
+ return;
109529
+ }
109530
+ try {
109531
+ keyringEntryFactory(REFRESH_TOKEN_SERVICE, sessionId).setPassword(
109532
+ refreshToken
109533
+ );
109534
+ deletePrefsRefreshToken(sessionId);
109535
+ } catch (_error) {
109536
+ setPrefsRefreshToken(sessionId, refreshToken);
109537
+ }
109538
+ };
109539
+ var deleteStoredRefreshToken = (sessionId) => {
109540
+ try {
109541
+ keyringEntryFactory(REFRESH_TOKEN_SERVICE, sessionId).deletePassword();
109542
+ } catch (_error) {
109543
+ }
109544
+ deletePrefsRefreshToken(sessionId);
109545
+ };
109546
+
109547
+ // lib/sdks.ts
109008
109548
  var getValidAccessToken = async (endpoint) => {
109009
109549
  const accessToken = globalConfig2.getAccessToken();
109010
- const refreshToken = globalConfig2.getRefreshToken();
109011
109550
  const tokenExpiry = globalConfig2.getTokenExpiry();
109012
109551
  const clientId = globalConfig2.getClientId() || OAUTH2_CLIENT_ID;
109552
+ const currentSession = globalConfig2.getCurrentSession();
109013
109553
  if (accessToken && tokenExpiry > Date.now() + 6e4) {
109014
109554
  return accessToken;
109015
109555
  }
109556
+ const refreshToken = currentSession ? getStoredRefreshToken(currentSession) : "";
109016
109557
  if (accessToken && tokenExpiry === 0 && !refreshToken) {
109017
109558
  return accessToken;
109018
109559
  }
@@ -109032,7 +109573,7 @@ var getValidAccessToken = async (endpoint) => {
109032
109573
  const newExpiry = Date.now() + token.expires_in * 1e3;
109033
109574
  globalConfig2.setAccessToken(token.access_token);
109034
109575
  if (token.refresh_token) {
109035
- globalConfig2.setRefreshToken(token.refresh_token);
109576
+ setStoredRefreshToken(currentSession, token.refresh_token);
109036
109577
  }
109037
109578
  globalConfig2.setTokenExpiry(newExpiry);
109038
109579
  return token.access_token;