appwrite-cli 22.1.3 → 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/cli.cjs CHANGED
@@ -26710,7 +26710,7 @@ var require_sbcs = __commonJS({
26710
26710
  return mod && mod.__esModule ? mod : { "default": mod };
26711
26711
  };
26712
26712
  Object.defineProperty(exports2, "__esModule", { value: true });
26713
- exports2.KOI8_R = exports2.windows_1256 = exports2.windows_1251 = exports2.ISO_8859_9 = exports2.ISO_8859_8 = exports2.ISO_8859_7 = exports2.ISO_8859_6 = exports2.ISO_8859_5 = exports2.ISO_8859_2 = exports2.ISO_8859_1 = void 0;
26713
+ exports2.KOI8_R = exports2.windows_874 = exports2.windows_1258 = exports2.windows_1257 = exports2.windows_1256 = exports2.windows_1251 = exports2.ISO_8859_9 = exports2.ISO_8859_8 = exports2.ISO_8859_7 = exports2.ISO_8859_6 = exports2.ISO_8859_5 = exports2.ISO_8859_2 = exports2.ISO_8859_1 = void 0;
26714
26714
  var match_1 = __importDefault(require_match());
26715
26715
  var N_GRAM_MASK = 16777215;
26716
26716
  var NGramParser = class {
@@ -30713,6 +30713,443 @@ var require_sbcs = __commonJS({
30713
30713
  }
30714
30714
  };
30715
30715
  exports2.windows_1256 = windows_1256;
30716
+ var windows_1257 = class extends sbcs {
30717
+ match(det) {
30718
+ return det.inputBytes.some((byte) => byte >= 128) ? super.match(det) : null;
30719
+ }
30720
+ byteMap() {
30721
+ const byteMap = new Array(256).fill(32);
30722
+ byteMap[39] = 0;
30723
+ for (let i = 65; i <= 90; i++)
30724
+ byteMap[i] = i + 32;
30725
+ for (let i = 97; i <= 122; i++)
30726
+ byteMap[i] = i;
30727
+ byteMap[142] = 142;
30728
+ byteMap[168] = byteMap[184] = 184;
30729
+ byteMap[170] = byteMap[186] = 186;
30730
+ byteMap[175] = byteMap[191] = 191;
30731
+ byteMap[181] = 181;
30732
+ for (let i = 192; i <= 214; i++)
30733
+ byteMap[i] = i + 32;
30734
+ for (let i = 216; i <= 222; i++)
30735
+ byteMap[i] = i + 32;
30736
+ byteMap[223] = 223;
30737
+ for (let i = 224; i <= 246; i++)
30738
+ byteMap[i] = i;
30739
+ for (let i = 248; i <= 254; i++)
30740
+ byteMap[i] = i;
30741
+ return byteMap;
30742
+ }
30743
+ ngrams() {
30744
+ return [
30745
+ new NGramsPlusLang("et", [
30746
+ 2122090,
30747
+ 2122098,
30748
+ 2123109,
30749
+ 2124135,
30750
+ 2124385,
30751
+ 2124641,
30752
+ 2124645,
30753
+ 2124649,
30754
+ 2124655,
30755
+ 2124661,
30756
+ 2124897,
30757
+ 2125417,
30758
+ 2125678,
30759
+ 2126441,
30760
+ 2126693,
30761
+ 2126949,
30762
+ 6365281,
30763
+ 6365290,
30764
+ 6365291,
30765
+ 6365292,
30766
+ 6382112,
30767
+ 6382624,
30768
+ 6384499,
30769
+ 6386549,
30770
+ 6386785,
30771
+ 6387297,
30772
+ 6561908,
30773
+ 6578464,
30774
+ 6583667,
30775
+ 6627435,
30776
+ 6627443,
30777
+ 6645100,
30778
+ 6645107,
30779
+ 6646816,
30780
+ 6646885,
30781
+ 6646900,
30782
+ 6648608,
30783
+ 6648692,
30784
+ 6889579,
30785
+ 6906912,
30786
+ 6910570,
30787
+ 6910752,
30788
+ 6971680,
30789
+ 7037299,
30790
+ 7038309,
30791
+ 7039346,
30792
+ 7040879,
30793
+ 7041893,
30794
+ 7041908,
30795
+ 7104875,
30796
+ 7107616,
30797
+ 7544929,
30798
+ 7544939,
30799
+ 7562528,
30800
+ 7562604,
30801
+ 7566437,
30802
+ 7566441,
30803
+ 7566708,
30804
+ 7627115,
30805
+ 7627124,
30806
+ 7629088,
30807
+ 7697184,
30808
+ 7697253,
30809
+ 7697505
30810
+ ]),
30811
+ new NGramsPlusLang("lv", [
30812
+ 2122098,
30813
+ 2122601,
30814
+ 2122849,
30815
+ 2124146,
30816
+ 2124154,
30817
+ 2124897,
30818
+ 2125282,
30819
+ 2125921,
30820
+ 2125938,
30821
+ 2126433,
30822
+ 2126689,
30823
+ 2126699,
30824
+ 2126949,
30825
+ 2127214,
30826
+ 2127457,
30827
+ 6365289,
30828
+ 6365301,
30829
+ 6365302,
30830
+ 6382185,
30831
+ 6383904,
30832
+ 6384499,
30833
+ 6384751,
30834
+ 6385778,
30835
+ 6386293,
30836
+ 6386464,
30837
+ 6386806,
30838
+ 6449509,
30839
+ 6452512,
30840
+ 6515052,
30841
+ 6515060,
30842
+ 6578464,
30843
+ 6578546,
30844
+ 6583584,
30845
+ 6584864,
30846
+ 6644850,
30847
+ 6646123,
30848
+ 6646643,
30849
+ 6647393,
30850
+ 6648608,
30851
+ 6680693,
30852
+ 6889577,
30853
+ 6907236,
30854
+ 6907376,
30855
+ 6908642,
30856
+ 6909046,
30857
+ 7041908,
30858
+ 7102836,
30859
+ 7106404,
30860
+ 7233824,
30861
+ 7300193,
30862
+ 7496043,
30863
+ 7501166,
30864
+ 7544947,
30865
+ 7544949,
30866
+ 7544950,
30867
+ 7566453,
30868
+ 7566574,
30869
+ 7632160,
30870
+ 7632489,
30871
+ 7676022,
30872
+ 7695904,
30873
+ 7697184,
30874
+ 7758188,
30875
+ 14840608
30876
+ ]),
30877
+ new NGramsPlusLang("lt", [
30878
+ 2122089,
30879
+ 2122341,
30880
+ 2124146,
30881
+ 2124641,
30882
+ 2124905,
30883
+ 2125167,
30884
+ 2126433,
30885
+ 2126689,
30886
+ 2126699,
30887
+ 2126709,
30888
+ 2126945,
30889
+ 2126949,
30890
+ 2126965,
30891
+ 2127457,
30892
+ 2127465,
30893
+ 6365300,
30894
+ 6365424,
30895
+ 6383904,
30896
+ 6383988,
30897
+ 6384112,
30898
+ 6384738,
30899
+ 6384993,
30900
+ 6385268,
30901
+ 6386274,
30902
+ 6386292,
30903
+ 6386976,
30904
+ 6387050,
30905
+ 6418553,
30906
+ 6447392,
30907
+ 6448489,
30908
+ 6448494,
30909
+ 6647401,
30910
+ 6648949,
30911
+ 6889569,
30912
+ 6889577,
30913
+ 6889579,
30914
+ 6889581,
30915
+ 6906217,
30916
+ 6907246,
30917
+ 6907252,
30918
+ 6909543,
30919
+ 6910496,
30920
+ 6910752,
30921
+ 6942827,
30922
+ 6971757,
30923
+ 6972704,
30924
+ 7037289,
30925
+ 7037292,
30926
+ 7103073,
30927
+ 7104869,
30928
+ 7170419,
30929
+ 7171947,
30930
+ 7269152,
30931
+ 7301733,
30932
+ 7302009,
30933
+ 7303968,
30934
+ 7496176,
30935
+ 7544937,
30936
+ 7544939,
30937
+ 7544950,
30938
+ 7564129,
30939
+ 7629088,
30940
+ 7632246,
30941
+ 7957356
30942
+ ])
30943
+ ];
30944
+ }
30945
+ name() {
30946
+ return "windows-1257";
30947
+ }
30948
+ };
30949
+ exports2.windows_1257 = windows_1257;
30950
+ var windows_1258 = class extends sbcs {
30951
+ match(det) {
30952
+ return det.inputBytes.some((byte) => byte >= 128) ? super.match(det) : null;
30953
+ }
30954
+ byteMap() {
30955
+ const byteMap = new Array(256).fill(32);
30956
+ byteMap[39] = 0;
30957
+ for (let i = 65; i <= 90; i++)
30958
+ byteMap[i] = i + 32;
30959
+ for (let i = 97; i <= 122; i++)
30960
+ byteMap[i] = i;
30961
+ byteMap[131] = 131;
30962
+ byteMap[136] = 136;
30963
+ byteMap[140] = byteMap[156] = 156;
30964
+ byteMap[159] = 255;
30965
+ byteMap[170] = 170;
30966
+ byteMap[181] = 181;
30967
+ byteMap[186] = 186;
30968
+ for (let i = 192; i <= 203; i++)
30969
+ byteMap[i] = i + 32;
30970
+ byteMap[204] = 204;
30971
+ for (let i = 205; i <= 209; i++)
30972
+ byteMap[i] = i + 32;
30973
+ byteMap[210] = 210;
30974
+ for (let i = 211; i <= 214; i++)
30975
+ byteMap[i] = i + 32;
30976
+ for (let i = 216; i <= 221; i++)
30977
+ byteMap[i] = i + 32;
30978
+ byteMap[222] = 222;
30979
+ byteMap[223] = 223;
30980
+ for (let i = 224; i <= 246; i++)
30981
+ byteMap[i] = i;
30982
+ for (let i = 248; i <= 253; i++)
30983
+ byteMap[i] = i;
30984
+ byteMap[255] = 255;
30985
+ return byteMap;
30986
+ }
30987
+ ngrams() {
30988
+ return [
30989
+ 2122600,
30990
+ 2122721,
30991
+ 2123625,
30992
+ 2123887,
30993
+ 2125415,
30994
+ 2125928,
30995
+ 2126952,
30996
+ 2126953,
30997
+ 2126962,
30998
+ 2127465,
30999
+ 2127584,
31000
+ 6419060,
31001
+ 6496355,
31002
+ 6496374,
31003
+ 6514720,
31004
+ 6514925,
31005
+ 6545763,
31006
+ 6758504,
31007
+ 6758510,
31008
+ 6758516,
31009
+ 6758518,
31010
+ 6812782,
31011
+ 6815198,
31012
+ 6815221,
31013
+ 6824052,
31014
+ 6844402,
31015
+ 6876526,
31016
+ 6889582,
31017
+ 6889588,
31018
+ 6941394,
31019
+ 6941420,
31020
+ 6941426,
31021
+ 7217251,
31022
+ 7217262,
31023
+ 7217268,
31024
+ 7235360,
31025
+ 7235572,
31026
+ 7235581,
31027
+ 7235616,
31028
+ 7302759,
31029
+ 7336547,
31030
+ 7610483,
31031
+ 7629053,
31032
+ 7629290,
31033
+ 7631471,
31034
+ 7676020,
31035
+ 7760362,
31036
+ 7790624,
31037
+ 13396256,
31038
+ 13397607,
31039
+ 14557288,
31040
+ 14771048,
31041
+ 15395950,
31042
+ 15397492,
31043
+ 15494759,
31044
+ 15496224,
31045
+ 15560296,
31046
+ 15885088,
31047
+ 15886624,
31048
+ 15887904,
31049
+ 15889440,
31050
+ 16018976,
31051
+ 16108649,
31052
+ 16643532
31053
+ ];
31054
+ }
31055
+ name() {
31056
+ return "windows-1258";
31057
+ }
31058
+ language() {
31059
+ return "vi";
31060
+ }
31061
+ };
31062
+ exports2.windows_1258 = windows_1258;
31063
+ var windows_874 = class extends sbcs {
31064
+ byteMap() {
31065
+ const byteMap = new Array(256).fill(32);
31066
+ byteMap[39] = 0;
31067
+ for (let i = 65; i <= 90; i++)
31068
+ byteMap[i] = i + 32;
31069
+ for (let i = 97; i <= 122; i++)
31070
+ byteMap[i] = i;
31071
+ for (let i = 161; i <= 218; i++)
31072
+ byteMap[i] = i;
31073
+ for (let i = 223; i <= 251; i++)
31074
+ byteMap[i] = i;
31075
+ return byteMap;
31076
+ }
31077
+ ngrams() {
31078
+ return [
31079
+ 2138578,
31080
+ 2138856,
31081
+ 2146514,
31082
+ 2148291,
31083
+ 2154949,
31084
+ 10604985,
31085
+ 10605251,
31086
+ 10669479,
31087
+ 10671554,
31088
+ 10799058,
31089
+ 11064263,
31090
+ 11195847,
31091
+ 11200960,
31092
+ 11200995,
31093
+ 11910083,
31094
+ 12042976,
31095
+ 12042979,
31096
+ 12047848,
31097
+ 12132544,
31098
+ 12165586,
31099
+ 12173522,
31100
+ 12305360,
31101
+ 12314553,
31102
+ 12636873,
31103
+ 12828960,
31104
+ 12829619,
31105
+ 12829633,
31106
+ 12832936,
31107
+ 12832994,
31108
+ 12837026,
31109
+ 13091779,
31110
+ 13095353,
31111
+ 13095617,
31112
+ 13096117,
31113
+ 13226679,
31114
+ 13226724,
31115
+ 13293544,
31116
+ 13477063,
31117
+ 13674707,
31118
+ 13689538,
31119
+ 13744416,
31120
+ 13805473,
31121
+ 13812171,
31122
+ 13812452,
31123
+ 13812512,
31124
+ 13812704,
31125
+ 13814226,
31126
+ 13821111,
31127
+ 13879249,
31128
+ 13940155,
31129
+ 14009017,
31130
+ 14010324,
31131
+ 14149837,
31132
+ 14721749,
31133
+ 14728167,
31134
+ 14796240,
31135
+ 14860964,
31136
+ 14920425,
31137
+ 14924193,
31138
+ 14989250,
31139
+ 15258279,
31140
+ 15262634,
31141
+ 15319250,
31142
+ 15328185
31143
+ ];
31144
+ }
31145
+ name() {
31146
+ return "windows-874";
31147
+ }
31148
+ language() {
31149
+ return "th";
31150
+ }
31151
+ };
31152
+ exports2.windows_874 = windows_874;
30716
31153
  var KOI8_R = class extends sbcs {
30717
31154
  byteMap() {
30718
31155
  return [
@@ -31264,6 +31701,9 @@ var require_lib = __commonJS({
31264
31701
  new sbcs.ISO_8859_9(),
31265
31702
  new sbcs.windows_1251(),
31266
31703
  new sbcs.windows_1256(),
31704
+ new sbcs.windows_1257(),
31705
+ new sbcs.windows_1258(),
31706
+ new sbcs.windows_874(),
31267
31707
  new sbcs.KOI8_R(),
31268
31708
  new ascii_1.default()
31269
31709
  ];
@@ -86099,7 +86539,7 @@ var package_default = {
86099
86539
  type: "module",
86100
86540
  homepage: "https://appwrite.io/support",
86101
86541
  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",
86102
- version: "22.1.3",
86542
+ version: "22.2.0",
86103
86543
  license: "BSD-3-Clause",
86104
86544
  main: "dist/index.cjs",
86105
86545
  module: "dist/index.js",
@@ -86131,9 +86571,9 @@ var package_default = {
86131
86571
  "build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
86132
86572
  "build:runtime": "npm run build:lib:runtime && npm run build:cli",
86133
86573
  "build:lib:runtime": "npm run build:lib:esm && npm run build:lib:cjs",
86134
- "build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --external:terminal-image --outfile=dist/index.js",
86135
- "build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:terminal-image --outfile=dist/index.cjs",
86136
- "build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --external:terminal-image --outfile=dist/cli.cjs",
86574
+ "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",
86575
+ "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",
86576
+ "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",
86137
86577
  lint: "eslint .",
86138
86578
  format: 'prettier --write "**/*.{js,ts,json,md}"',
86139
86579
  generate: "tsx scripts/generate-commands.ts",
@@ -86147,7 +86587,8 @@ var package_default = {
86147
86587
  "windows-arm64": "bun build cli.ts --compile --minify --target=bun-windows-arm64 --outfile build/appwrite-cli-win-arm64.exe"
86148
86588
  },
86149
86589
  dependencies: {
86150
- "@appwrite.io/console": "^15.1.0",
86590
+ "@appwrite.io/console": "^15.1.1",
86591
+ "@napi-rs/keyring": "^1.3.0",
86151
86592
  chalk: "4.1.2",
86152
86593
  chokidar: "^3.6.0",
86153
86594
  "cli-progress": "^3.12.0",
@@ -100830,7 +101271,7 @@ var validateCrossDatabase = (data, ctx) => {
100830
101271
  // lib/constants.ts
100831
101272
  var SDK_TITLE = "Appwrite";
100832
101273
  var SDK_TITLE_LOWER = "appwrite";
100833
- var SDK_VERSION = "22.1.3";
101274
+ var SDK_VERSION = "22.2.0";
100834
101275
  var SDK_NAME = "Command Line";
100835
101276
  var SDK_PLATFORM = "console";
100836
101277
  var SDK_LANGUAGE = "cli";
@@ -101437,7 +101878,7 @@ var Client = class _Client {
101437
101878
  "x-sdk-name": "Console",
101438
101879
  "x-sdk-platform": "console",
101439
101880
  "x-sdk-language": "web",
101440
- "x-sdk-version": "15.1.0",
101881
+ "x-sdk-version": "15.1.1",
101441
101882
  "X-Appwrite-Response-Format": "1.9.5"
101442
101883
  };
101443
101884
  this.realtime = {
@@ -108967,15 +109408,21 @@ var Functions = class {
108967
109408
  };
108968
109409
  return this.client.call("get", uri, apiHeaders, payload);
108969
109410
  }
108970
- /**
108971
- * List allowed function specifications for this instance.
108972
- *
108973
- * @throws {AppwriteException}
108974
- * @returns {Promise<Models.SpecificationList>}
108975
- */
108976
- listSpecifications() {
109411
+ listSpecifications(paramsOrFirst) {
109412
+ let params;
109413
+ if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
109414
+ params = paramsOrFirst || {};
109415
+ } else {
109416
+ params = {
109417
+ type: paramsOrFirst
109418
+ };
109419
+ }
109420
+ const type = params.type;
108977
109421
  const apiPath = "/functions/specifications";
108978
109422
  const payload = {};
109423
+ if (typeof type !== "undefined") {
109424
+ payload["type"] = type;
109425
+ }
108979
109426
  const uri = new URL(this.client.config.endpoint + apiPath);
108980
109427
  const apiHeaders = {
108981
109428
  "X-Appwrite-Project": this.client.config.project,
@@ -110275,28 +110722,6 @@ var Health = class {
110275
110722
  };
110276
110723
  return this.client.call("get", uri, apiHeaders, payload);
110277
110724
  }
110278
- getQueuePriorityBuilds(paramsOrFirst) {
110279
- let params;
110280
- if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
110281
- params = paramsOrFirst || {};
110282
- } else {
110283
- params = {
110284
- threshold: paramsOrFirst
110285
- };
110286
- }
110287
- const threshold = params.threshold;
110288
- const apiPath = "/health/queue/builds-priority";
110289
- const payload = {};
110290
- if (typeof threshold !== "undefined") {
110291
- payload["threshold"] = threshold;
110292
- }
110293
- const uri = new URL(this.client.config.endpoint + apiPath);
110294
- const apiHeaders = {
110295
- "X-Appwrite-Project": this.client.config.project,
110296
- "accept": "application/json"
110297
- };
110298
- return this.client.call("get", uri, apiHeaders, payload);
110299
- }
110300
110725
  getQueueCertificates(paramsOrFirst) {
110301
110726
  let params;
110302
110727
  if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
@@ -121136,15 +121561,21 @@ var Sites = class {
121136
121561
  };
121137
121562
  return this.client.call("get", uri, apiHeaders, payload);
121138
121563
  }
121139
- /**
121140
- * List allowed site specifications for this instance.
121141
- *
121142
- * @throws {AppwriteException}
121143
- * @returns {Promise<Models.SpecificationList>}
121144
- */
121145
- listSpecifications() {
121564
+ listSpecifications(paramsOrFirst) {
121565
+ let params;
121566
+ if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
121567
+ params = paramsOrFirst || {};
121568
+ } else {
121569
+ params = {
121570
+ type: paramsOrFirst
121571
+ };
121572
+ }
121573
+ const type = params.type;
121146
121574
  const apiPath = "/sites/specifications";
121147
121575
  const payload = {};
121576
+ if (typeof type !== "undefined") {
121577
+ payload["type"] = type;
121578
+ }
121148
121579
  const uri = new URL(this.client.config.endpoint + apiPath);
121149
121580
  const apiHeaders = {
121150
121581
  "X-Appwrite-Project": this.client.config.project,
@@ -131716,8 +132147,8 @@ function openBrowser(url2) {
131716
132147
  let args;
131717
132148
  switch (process.platform) {
131718
132149
  case "win32":
131719
- command = "cmd";
131720
- args = ["/c", "start", "", `"${url2}"`];
132150
+ command = "rundll32";
132151
+ args = ["url.dll,FileProtocolHandler", url2];
131721
132152
  break;
131722
132153
  case "darwin":
131723
132154
  command = "open";
@@ -132905,6 +133336,9 @@ var Global = class _Global extends Config {
132905
133336
  setCookie(cookie) {
132906
133337
  this.setTo(_Global.PREFERENCE_COOKIE, cookie);
132907
133338
  }
133339
+ removeCookie() {
133340
+ this.deleteFrom(_Global.PREFERENCE_COOKIE);
133341
+ }
132908
133342
  getProject() {
132909
133343
  if (!this.hasFrom(_Global.PREFERENCE_PROJECT)) {
132910
133344
  return "";
@@ -132982,6 +133416,16 @@ var Global = class _Global extends Config {
132982
133416
  this.write();
132983
133417
  }
132984
133418
  }
133419
+ deleteFrom(key) {
133420
+ const current = this.getCurrentSession();
133421
+ if (current) {
133422
+ const config2 = this.get(current);
133423
+ if (config2 && config2[key] !== void 0) {
133424
+ delete config2[key];
133425
+ this.write();
133426
+ }
133427
+ }
133428
+ }
132985
133429
  };
132986
133430
  var localConfig = new Local();
132987
133431
  var globalConfig2 = new Global();
@@ -134624,14 +135068,75 @@ var import_chalk3 = __toESM(require_source(), 1);
134624
135068
 
134625
135069
  // lib/sdks.ts
134626
135070
  var import_os5 = __toESM(require("os"), 1);
135071
+
135072
+ // lib/auth/refresh-token.ts
135073
+ var import_keyring = require("@napi-rs/keyring");
135074
+ var REFRESH_TOKEN_SERVICE = `${EXECUTABLE_NAME}-oauth-refresh-token`;
135075
+ var keyringEntryFactory = (service, account2) => new import_keyring.Entry(service, account2);
135076
+ var getSessionData = (sessionId) => globalConfig2.get(sessionId);
135077
+ var setSessionData = (sessionId, data) => {
135078
+ globalConfig2.addSession(sessionId, data);
135079
+ };
135080
+ var setPrefsRefreshToken = (sessionId, refreshToken) => {
135081
+ const session = getSessionData(sessionId);
135082
+ if (!session) return;
135083
+ setSessionData(sessionId, {
135084
+ ...session,
135085
+ refreshToken
135086
+ });
135087
+ };
135088
+ var deletePrefsRefreshToken = (sessionId) => {
135089
+ const session = getSessionData(sessionId);
135090
+ if (!session?.refreshToken) return;
135091
+ const { refreshToken: _refreshToken, ...rest } = session;
135092
+ setSessionData(sessionId, rest);
135093
+ };
135094
+ var getStoredRefreshToken = (sessionId) => {
135095
+ try {
135096
+ const refreshToken = keyringEntryFactory(
135097
+ REFRESH_TOKEN_SERVICE,
135098
+ sessionId
135099
+ ).getPassword();
135100
+ if (refreshToken) {
135101
+ return refreshToken;
135102
+ }
135103
+ } catch (_error) {
135104
+ }
135105
+ return getSessionData(sessionId)?.refreshToken ?? "";
135106
+ };
135107
+ var hasStoredRefreshToken = (sessionId) => getStoredRefreshToken(sessionId) !== "";
135108
+ var setStoredRefreshToken = (sessionId, refreshToken) => {
135109
+ if (!refreshToken) {
135110
+ deleteStoredRefreshToken(sessionId);
135111
+ return;
135112
+ }
135113
+ try {
135114
+ keyringEntryFactory(REFRESH_TOKEN_SERVICE, sessionId).setPassword(
135115
+ refreshToken
135116
+ );
135117
+ deletePrefsRefreshToken(sessionId);
135118
+ } catch (_error) {
135119
+ setPrefsRefreshToken(sessionId, refreshToken);
135120
+ }
135121
+ };
135122
+ var deleteStoredRefreshToken = (sessionId) => {
135123
+ try {
135124
+ keyringEntryFactory(REFRESH_TOKEN_SERVICE, sessionId).deletePassword();
135125
+ } catch (_error) {
135126
+ }
135127
+ deletePrefsRefreshToken(sessionId);
135128
+ };
135129
+
135130
+ // lib/sdks.ts
134627
135131
  var getValidAccessToken = async (endpoint) => {
134628
135132
  const accessToken = globalConfig2.getAccessToken();
134629
- const refreshToken = globalConfig2.getRefreshToken();
134630
135133
  const tokenExpiry = globalConfig2.getTokenExpiry();
134631
135134
  const clientId = globalConfig2.getClientId() || OAUTH2_CLIENT_ID;
135135
+ const currentSession = globalConfig2.getCurrentSession();
134632
135136
  if (accessToken && tokenExpiry > Date.now() + 6e4) {
134633
135137
  return accessToken;
134634
135138
  }
135139
+ const refreshToken = currentSession ? getStoredRefreshToken(currentSession) : "";
134635
135140
  if (accessToken && tokenExpiry === 0 && !refreshToken) {
134636
135141
  return accessToken;
134637
135142
  }
@@ -134651,7 +135156,7 @@ var getValidAccessToken = async (endpoint) => {
134651
135156
  const newExpiry = Date.now() + token.expires_in * 1e3;
134652
135157
  globalConfig2.setAccessToken(token.access_token);
134653
135158
  if (token.refresh_token) {
134654
- globalConfig2.setRefreshToken(token.refresh_token);
135159
+ setStoredRefreshToken(currentSession, token.refresh_token);
134655
135160
  }
134656
135161
  globalConfig2.setTokenExpiry(newExpiry);
134657
135162
  return token.access_token;
@@ -135609,21 +136114,21 @@ var questionsLogout = [
135609
136114
  {
135610
136115
  type: "checkbox",
135611
136116
  name: "accounts",
135612
- message: "Select accounts to logout from",
136117
+ message: "Select accounts to log out",
135613
136118
  validate: (value) => validateRequired("account", value),
135614
136119
  choices() {
135615
136120
  const sessions = globalConfig2.getSessions();
135616
136121
  const current = globalConfig2.getCurrentSession();
135617
136122
  const data = [];
135618
- const longestEmail = sessions.reduce(
135619
- (prev, current2) => prev && (prev.email ?? "").length > (current2.email ?? "").length ? prev : current2
135620
- ).email.length;
135621
136123
  sessions.forEach((session) => {
135622
136124
  if (session.email) {
136125
+ const isCurrent = current === session.id;
136126
+ const currentLabel = isCurrent ? ` ${import_chalk3.default.green.bold("(current)")}` : "";
135623
136127
  data.push({
135624
- current: current === session.id,
136128
+ current: isCurrent,
135625
136129
  value: session.id,
135626
- name: `${session.email.padEnd(longestEmail)} ${current === session.id ? import_chalk3.default.green.bold("current") : " ".repeat(6)} ${session.endpoint}`
136130
+ name: `${session.email}${currentLabel} - ${session.endpoint}`,
136131
+ short: `${session.email}${isCurrent ? " (current)" : ""}`
135627
136132
  });
135628
136133
  }
135629
136134
  });
@@ -136284,6 +136789,7 @@ var Client3 = class _Client {
136284
136789
  );
136285
136790
  const current = globalConfig2.getCurrentSession();
136286
136791
  globalConfig2.setCurrentSession("");
136792
+ deleteStoredRefreshToken(current);
136287
136793
  globalConfig2.removeSession(current);
136288
136794
  }
136289
136795
  const isUnauthorized = json3.code === 401 && json3.type === "general_unauthorized_scope" && typeof json3.message === "string" && /role:\s*guests/i.test(json3.message);
@@ -136356,7 +136862,7 @@ var createLegacyConsoleClient = (endpoint, selfSigned = globalConfig2.getSelfSig
136356
136862
  var hasAuthSession = () => globalConfig2.getAccessToken() !== "" || globalConfig2.getCookie() !== "";
136357
136863
  var isLocalOnlySession = (sessionId) => {
136358
136864
  const session = getSession(sessionId);
136359
- return Boolean(session && !session.refreshToken && !session.cookie);
136865
+ return Boolean(session && !hasStoredRefreshToken(sessionId) && !session.cookie);
136360
136866
  };
136361
136867
  var isLegacySession = (sessionId) => {
136362
136868
  const session = getSession(sessionId);
@@ -136385,6 +136891,7 @@ var restoreCurrentSessionFallback = (preferredSessionId, fallbackSessionIds) =>
136385
136891
  var removeCurrentSession = () => {
136386
136892
  const current = globalConfig2.getCurrentSession();
136387
136893
  globalConfig2.setCurrentSession("");
136894
+ deleteStoredRefreshToken(current);
136388
136895
  globalConfig2.removeSession(current);
136389
136896
  };
136390
136897
  var deleteServerSession = async (sessionId) => {
@@ -136393,10 +136900,11 @@ var deleteServerSession = async (sessionId) => {
136393
136900
  return { deleted: false };
136394
136901
  }
136395
136902
  try {
136396
- if (session.refreshToken) {
136903
+ const refreshToken = getStoredRefreshToken(sessionId);
136904
+ if (refreshToken) {
136397
136905
  await revokeRefreshToken(
136398
136906
  session.endpoint,
136399
- session.refreshToken,
136907
+ refreshToken,
136400
136908
  session.clientId || OAUTH2_CLIENT_ID
136401
136909
  );
136402
136910
  return { deleted: true };
@@ -136426,12 +136934,14 @@ var logoutSessions = async (sessionIds) => {
136426
136934
  const errors = [];
136427
136935
  for (const sessionId of sessionIds) {
136428
136936
  if (isLocalOnlySession(sessionId)) {
136937
+ deleteStoredRefreshToken(sessionId);
136429
136938
  globalConfig2.removeSession(sessionId);
136430
136939
  continue;
136431
136940
  }
136432
136941
  globalConfig2.setCurrentSession(sessionId);
136433
136942
  const result = await deleteServerSession(sessionId);
136434
136943
  if (result.deleted) {
136944
+ deleteStoredRefreshToken(sessionId);
136435
136945
  globalConfig2.removeSession(sessionId);
136436
136946
  } else {
136437
136947
  failed++;
@@ -136452,6 +136962,7 @@ var removeLegacySessionsExcept = async (sessionIdToKeep) => {
136452
136962
  }
136453
136963
  const result = await deleteServerSession(sessionId);
136454
136964
  if (result.deleted) {
136965
+ deleteStoredRefreshToken(sessionId);
136455
136966
  globalConfig2.removeSession(sessionId);
136456
136967
  removed++;
136457
136968
  } else {
@@ -136515,16 +137026,13 @@ var listenForBrowserOpen = (url2, onCancel) => {
136515
137026
  if (shouldRestoreRawMode) {
136516
137027
  stdin.setRawMode?.(true);
136517
137028
  }
136518
- const shouldPause = stdin.isPaused();
136519
137029
  stdin.resume();
136520
137030
  const cleanup = () => {
136521
137031
  stdin.off("data", onData);
136522
137032
  if (shouldRestoreRawMode) {
136523
137033
  stdin.setRawMode?.(false);
136524
137034
  }
136525
- if (shouldPause) {
136526
- stdin.pause();
136527
- }
137035
+ stdin.pause();
136528
137036
  };
136529
137037
  let opened = false;
136530
137038
  const onData = (data) => {
@@ -136749,7 +137257,7 @@ To sign in, confirm the code below in your browser:
136749
137257
  }
136750
137258
  const tokenExpiry = Date.now() + token.expires_in * 1e3;
136751
137259
  globalConfig2.setAccessToken(token.access_token);
136752
- globalConfig2.setRefreshToken(token.refresh_token || "");
137260
+ setStoredRefreshToken(id, token.refresh_token || "");
136753
137261
  globalConfig2.setTokenExpiry(tokenExpiry);
136754
137262
  let tokenEmail = "";
136755
137263
  if (token.id_token) {
@@ -136771,6 +137279,7 @@ To sign in, confirm the code below in your browser:
136771
137279
  throw err;
136772
137280
  }
136773
137281
  globalConfig2.setEmail(account2.email);
137282
+ globalConfig2.removeCookie();
136774
137283
  const { removed: removedLegacySessions, failed: failedLegacySessions } = await removeLegacySessionsExcept(id);
136775
137284
  success2("Successfully signed in as " + globalConfig2.getEmail());
136776
137285
  if (removedLegacySessions > 0) {
@@ -151442,9 +151951,9 @@ var functionsListRuntimesCommand = functions.command(`list-runtimes`).descriptio
151442
151951
  async () => parse3(await (await getFunctionsClient()).listRuntimes())
151443
151952
  )
151444
151953
  );
151445
- var functionsListSpecificationsCommand = functions.command(`list-specifications`).description(`List allowed function specifications for this instance.`).action(
151954
+ var functionsListSpecificationsCommand = functions.command(`list-specifications`).description(`List allowed function specifications for this instance.`).option(`--type <type>`, `Specification type to list. Can be one of: runtimes, builds.`).action(
151446
151955
  actionRunner(
151447
- async () => parse3(await (await getFunctionsClient()).listSpecifications())
151956
+ async ({ type }) => parse3(await (await getFunctionsClient()).listSpecifications(type))
151448
151957
  )
151449
151958
  );
151450
151959
  var functionsListTemplatesCommand = functions.command(`list-templates`).description(`List available function templates. You can use template details in createFunction method.`).option(`--runtimes [runtimes...]`, `List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed.`).option(`--use-cases [use-cases...]`, `List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed.`).option(`--limit <limit>`, `Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.`, parseInteger).option(`--offset <offset>`, `Offset the list of returned templates. Maximum offset is 5000.`, parseInteger).option(
@@ -153830,9 +154339,9 @@ var sitesListFrameworksCommand = sites.command(`list-frameworks`).description(`G
153830
154339
  async () => parse3(await (await getSitesClient()).listFrameworks())
153831
154340
  )
153832
154341
  );
153833
- var sitesListSpecificationsCommand = sites.command(`list-specifications`).description(`List allowed site specifications for this instance.`).action(
154342
+ var sitesListSpecificationsCommand = sites.command(`list-specifications`).description(`List allowed site specifications for this instance.`).option(`--type <type>`, `Specification type to list. Can be one of: runtimes, builds.`).action(
153834
154343
  actionRunner(
153835
- async () => parse3(await (await getSitesClient()).listSpecifications())
154344
+ async ({ type }) => parse3(await (await getSitesClient()).listSpecifications(type))
153836
154345
  )
153837
154346
  );
153838
154347
  var sitesListTemplatesCommand = sites.command(`list-templates`).description(`List available site templates. You can use template details in createSite method.`).option(`--frameworks [frameworks...]`, `List of frameworks allowed for filtering site templates. Maximum of 100 frameworks are allowed.`).option(`--use-cases [use-cases...]`, `List of use cases allowed for filtering site templates. Maximum of 100 use cases are allowed.`).option(`--limit <limit>`, `Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.`, parseInteger).option(`--offset <offset>`, `Offset the list of returned templates. Maximum offset is 5000.`, parseInteger).action(