@muze-nl/jsfs-solid 0.2.3 → 0.3.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/browser.js CHANGED
@@ -4634,19 +4634,19 @@
4634
4634
  next();
4635
4635
  }
4636
4636
  };
4637
- readable._destroy = function(error2, cb) {
4637
+ readable._destroy = function(error3, cb) {
4638
4638
  PromisePrototypeThen(
4639
- close(error2),
4640
- () => process.nextTick(cb, error2),
4639
+ close(error3),
4640
+ () => process.nextTick(cb, error3),
4641
4641
  // nextTick is here in case cb throws
4642
- (e) => process.nextTick(cb, e || error2)
4642
+ (e) => process.nextTick(cb, e || error3)
4643
4643
  );
4644
4644
  };
4645
- async function close(error2) {
4646
- const hadError = error2 !== void 0 && error2 !== null;
4645
+ async function close(error3) {
4646
+ const hadError = error3 !== void 0 && error3 !== null;
4647
4647
  const hasThrow = typeof iterator.throw === "function";
4648
4648
  if (hadError && hasThrow) {
4649
- const { value, done } = await iterator.throw(error2);
4649
+ const { value, done } = await iterator.throw(error3);
4650
4650
  await value;
4651
4651
  if (done) {
4652
4652
  return;
@@ -4855,12 +4855,12 @@
4855
4855
  this.destroy(err);
4856
4856
  };
4857
4857
  Readable2.prototype[SymbolAsyncDispose] = function() {
4858
- let error2;
4858
+ let error3;
4859
4859
  if (!this.destroyed) {
4860
- error2 = this.readableEnded ? null : new AbortError();
4861
- this.destroy(error2);
4860
+ error3 = this.readableEnded ? null : new AbortError();
4861
+ this.destroy(error3);
4862
4862
  }
4863
- return new Promise2((resolve, reject) => eos(this, (err) => err && err !== error2 ? reject(err) : resolve(null)));
4863
+ return new Promise2((resolve, reject) => eos(this, (err) => err && err !== error3 ? reject(err) : resolve(null)));
4864
4864
  };
4865
4865
  Readable2.prototype.push = function(chunk, encoding) {
4866
4866
  return readableAddChunk(this, chunk, encoding, false);
@@ -5413,14 +5413,14 @@
5413
5413
  }
5414
5414
  }
5415
5415
  stream.on("readable", next);
5416
- let error2;
5416
+ let error3;
5417
5417
  const cleanup = eos(
5418
5418
  stream,
5419
5419
  {
5420
5420
  writable: false
5421
5421
  },
5422
5422
  (err) => {
5423
- error2 = err ? aggregateTwoErrors(error2, err) : null;
5423
+ error3 = err ? aggregateTwoErrors(error3, err) : null;
5424
5424
  callback();
5425
5425
  callback = nop;
5426
5426
  }
@@ -5430,19 +5430,19 @@
5430
5430
  const chunk = stream.destroyed ? null : stream.read();
5431
5431
  if (chunk !== null) {
5432
5432
  yield chunk;
5433
- } else if (error2) {
5434
- throw error2;
5435
- } else if (error2 === null) {
5433
+ } else if (error3) {
5434
+ throw error3;
5435
+ } else if (error3 === null) {
5436
5436
  return;
5437
5437
  } else {
5438
5438
  await new Promise2(next);
5439
5439
  }
5440
5440
  }
5441
5441
  } catch (err) {
5442
- error2 = aggregateTwoErrors(error2, err);
5443
- throw error2;
5442
+ error3 = aggregateTwoErrors(error3, err);
5443
+ throw error3;
5444
5444
  } finally {
5445
- if ((error2 || (options === null || options === void 0 ? void 0 : options.destroyOnReturn) !== false) && (error2 === void 0 || stream._readableState.autoDestroy)) {
5445
+ if ((error3 || (options === null || options === void 0 ? void 0 : options.destroyOnReturn) !== false) && (error3 === void 0 || stream._readableState.autoDestroy)) {
5446
5446
  destroyImpl.destroyer(stream, null);
5447
5447
  } else {
5448
5448
  stream.off("readable", next);
@@ -6936,11 +6936,11 @@
6936
6936
  yield* Readable2.prototype[SymbolAsyncIterator].call(val);
6937
6937
  }
6938
6938
  async function pumpToNode(iterable, writable, finish, { end }) {
6939
- let error2;
6939
+ let error3;
6940
6940
  let onresolve = null;
6941
6941
  const resume = (err) => {
6942
6942
  if (err) {
6943
- error2 = err;
6943
+ error3 = err;
6944
6944
  }
6945
6945
  if (onresolve) {
6946
6946
  const callback = onresolve;
@@ -6949,12 +6949,12 @@
6949
6949
  }
6950
6950
  };
6951
6951
  const wait = () => new Promise2((resolve, reject) => {
6952
- if (error2) {
6953
- reject(error2);
6952
+ if (error3) {
6953
+ reject(error3);
6954
6954
  } else {
6955
6955
  onresolve = () => {
6956
- if (error2) {
6957
- reject(error2);
6956
+ if (error3) {
6957
+ reject(error3);
6958
6958
  } else {
6959
6959
  resolve();
6960
6960
  }
@@ -6984,7 +6984,7 @@
6984
6984
  }
6985
6985
  finish();
6986
6986
  } catch (err) {
6987
- finish(error2 !== err ? aggregateTwoErrors(error2, err) : err);
6987
+ finish(error3 !== err ? aggregateTwoErrors(error3, err) : err);
6988
6988
  } finally {
6989
6989
  cleanup();
6990
6990
  writable.off("drain", resume);
@@ -7038,7 +7038,7 @@
7038
7038
  if (outerSignal) {
7039
7039
  disposable = addAbortListener(outerSignal, abort);
7040
7040
  }
7041
- let error2;
7041
+ let error3;
7042
7042
  let value;
7043
7043
  const destroys = [];
7044
7044
  let finishCount = 0;
@@ -7047,23 +7047,23 @@
7047
7047
  }
7048
7048
  function finishImpl(err, final) {
7049
7049
  var _disposable;
7050
- if (err && (!error2 || error2.code === "ERR_STREAM_PREMATURE_CLOSE")) {
7051
- error2 = err;
7050
+ if (err && (!error3 || error3.code === "ERR_STREAM_PREMATURE_CLOSE")) {
7051
+ error3 = err;
7052
7052
  }
7053
- if (!error2 && !final) {
7053
+ if (!error3 && !final) {
7054
7054
  return;
7055
7055
  }
7056
7056
  while (destroys.length) {
7057
- destroys.shift()(error2);
7057
+ destroys.shift()(error3);
7058
7058
  }
7059
7059
  ;
7060
7060
  (_disposable = disposable) === null || _disposable === void 0 ? void 0 : _disposable[SymbolDispose]();
7061
7061
  ac.abort();
7062
7062
  if (final) {
7063
- if (!error2) {
7063
+ if (!error3) {
7064
7064
  lastStreamCleanup.forEach((fn) => fn());
7065
7065
  }
7066
- process.nextTick(callback, error2, value);
7066
+ process.nextTick(callback, error3, value);
7067
7067
  }
7068
7068
  }
7069
7069
  let ret;
@@ -9100,7 +9100,7 @@
9100
9100
  }
9101
9101
 
9102
9102
  // node_modules/@muze-nl/metro/src/mw/getdata.mjs
9103
- function getdatamw() {
9103
+ function getdatamw2() {
9104
9104
  return async function getdata(req, next) {
9105
9105
  let res = await next(req);
9106
9106
  if (res.ok && res.data) {
@@ -9114,9 +9114,9 @@
9114
9114
  var API = class extends Client {
9115
9115
  constructor(base, methods, bind = null) {
9116
9116
  if (base instanceof Client) {
9117
- super(base.clientOptions, throwermw(), getdatamw());
9117
+ super(base.clientOptions, throwermw(), getdatamw2());
9118
9118
  } else {
9119
- super(base, throwermw(), getdatamw());
9119
+ super(base, throwermw(), getdatamw2());
9120
9120
  }
9121
9121
  if (!bind) {
9122
9122
  bind = this;
@@ -9153,7 +9153,7 @@
9153
9153
  mw: {
9154
9154
  json: jsonmw,
9155
9155
  thrower: throwermw,
9156
- getdata: getdatamw
9156
+ getdata: getdatamw2
9157
9157
  },
9158
9158
  api,
9159
9159
  jsonApi
@@ -9163,6 +9163,20 @@
9163
9163
  }
9164
9164
  var everything_default = metro2;
9165
9165
 
9166
+ // node_modules/@muze-nl/metro-oauth2/src/oauth2.mjs
9167
+ var oauth2_exports = {};
9168
+ __export(oauth2_exports, {
9169
+ base64url_encode: () => base64url_encode,
9170
+ createState: () => createState,
9171
+ default: () => oauth2mw,
9172
+ generateCodeChallenge: () => generateCodeChallenge,
9173
+ generateCodeVerifier: () => generateCodeVerifier,
9174
+ getExpires: () => getExpires,
9175
+ isAuthorized: () => isAuthorized,
9176
+ isExpired: () => isExpired,
9177
+ isRedirected: () => isRedirected
9178
+ });
9179
+
9166
9180
  // node_modules/@muze-nl/assert/src/assert.mjs
9167
9181
  globalThis.assertEnabled = false;
9168
9182
  function enable() {
@@ -9456,9 +9470,9 @@
9456
9470
  }
9457
9471
  };
9458
9472
  assert(options, {});
9459
- const oauth2 = Object.assign({}, defaultOptions.oauth2_configuration, options?.oauth2_configuration);
9473
+ const oauth22 = Object.assign({}, defaultOptions.oauth2_configuration, options?.oauth2_configuration);
9460
9474
  options = Object.assign({}, defaultOptions, options);
9461
- options.oauth2_configuration = oauth2;
9475
+ options.oauth2_configuration = oauth22;
9462
9476
  const store = tokenStore(options.site);
9463
9477
  if (!options.tokens) {
9464
9478
  options.tokens = store.tokens;
@@ -9475,12 +9489,12 @@
9475
9489
  redirect_uri: Required(validURL)
9476
9490
  }
9477
9491
  });
9478
- for (let option in oauth2) {
9492
+ for (let option in oauth22) {
9479
9493
  switch (option) {
9480
9494
  case "access_token":
9481
9495
  case "authorization_code":
9482
9496
  case "refresh_token":
9483
- options.tokens.set(option, oauth2[option]);
9497
+ options.tokens.set(option, oauth22[option]);
9484
9498
  break;
9485
9499
  }
9486
9500
  }
@@ -9577,7 +9591,7 @@
9577
9591
  }
9578
9592
  }
9579
9593
  async function fetchAccessToken() {
9580
- if (oauth2.grant_type === "authorization_code" && !options.tokens.has("authorization_code")) {
9594
+ if (oauth22.grant_type === "authorization_code" && !options.tokens.has("authorization_code")) {
9581
9595
  let authReqURL = await getAuthorizationCodeURL();
9582
9596
  if (!options.authorize_callback || typeof options.authorize_callback !== "function") {
9583
9597
  throw metroError("oauth2mw: oauth2 with grant_type:authorization_code requires a callback function in client options.authorize_callback");
@@ -9635,11 +9649,11 @@
9635
9649
  return data;
9636
9650
  }
9637
9651
  async function getAuthorizationCodeURL() {
9638
- if (!oauth2.authorization_endpoint) {
9652
+ if (!oauth22.authorization_endpoint) {
9639
9653
  throw metroError("oauth2mw: Missing options.oauth2_configuration.authorization_endpoint");
9640
9654
  }
9641
- let url2 = url(oauth2.authorization_endpoint, { hash: "" });
9642
- assert(oauth2, {
9655
+ let url2 = url(oauth22.authorization_endpoint, { hash: "" });
9656
+ assert(oauth22, {
9643
9657
  client_id: /.+/,
9644
9658
  redirect_uri: /.+/,
9645
9659
  scope: /.*/
@@ -9647,56 +9661,56 @@
9647
9661
  let search = {
9648
9662
  response_type: "code",
9649
9663
  // implicit flow uses 'token' here, but is not considered safe, so not supported
9650
- client_id: oauth2.client_id,
9651
- redirect_uri: oauth2.redirect_uri,
9652
- state: oauth2.state || createState(40)
9664
+ client_id: oauth22.client_id,
9665
+ redirect_uri: oauth22.redirect_uri,
9666
+ state: oauth22.state || createState(40)
9653
9667
  // OAuth2.1 RFC says optional, but its a good idea to always add/check it
9654
9668
  };
9655
- if (oauth2.response_type) {
9656
- search.response_type = oauth2.response_type;
9669
+ if (oauth22.response_type) {
9670
+ search.response_type = oauth22.response_type;
9657
9671
  }
9658
- if (oauth2.response_mode) {
9659
- search.response_mode = oauth2.response_mode;
9672
+ if (oauth22.response_mode) {
9673
+ search.response_mode = oauth22.response_mode;
9660
9674
  }
9661
9675
  options.state.set(search.state);
9662
- if (oauth2.client_secret) {
9663
- search.client_secret = oauth2.client_secret;
9676
+ if (oauth22.client_secret) {
9677
+ search.client_secret = oauth22.client_secret;
9664
9678
  }
9665
- if (oauth2.code_verifier) {
9666
- options.tokens.set("code_verifier", oauth2.code_verifier);
9667
- search.code_challenge = await generateCodeChallenge(oauth2.code_verifier);
9679
+ if (oauth22.code_verifier) {
9680
+ options.tokens.set("code_verifier", oauth22.code_verifier);
9681
+ search.code_challenge = await generateCodeChallenge(oauth22.code_verifier);
9668
9682
  search.code_challenge_method = "S256";
9669
9683
  }
9670
- if (oauth2.scope) {
9671
- search.scope = oauth2.scope;
9684
+ if (oauth22.scope) {
9685
+ search.scope = oauth22.scope;
9672
9686
  }
9673
- if (oauth2.prompt) {
9674
- search.prompt = oauth2.prompt;
9687
+ if (oauth22.prompt) {
9688
+ search.prompt = oauth22.prompt;
9675
9689
  }
9676
9690
  return url(url2, { search });
9677
9691
  }
9678
9692
  function getAccessTokenRequest(grant_type = null) {
9679
- assert(oauth2, {
9693
+ assert(oauth22, {
9680
9694
  client_id: /.+/,
9681
9695
  redirect_uri: /.+/
9682
9696
  });
9683
- if (!oauth2.token_endpoint) {
9697
+ if (!oauth22.token_endpoint) {
9684
9698
  throw metroError("oauth2mw: Missing options.endpoints.token url");
9685
9699
  }
9686
- let url2 = url(oauth2.token_endpoint, { hash: "" });
9700
+ let url2 = url(oauth22.token_endpoint, { hash: "" });
9687
9701
  let params = {
9688
- grant_type: grant_type || oauth2.grant_type,
9689
- client_id: oauth2.client_id
9702
+ grant_type: grant_type || oauth22.grant_type,
9703
+ client_id: oauth22.client_id
9690
9704
  };
9691
- if (oauth2.client_secret) {
9692
- params.client_secret = oauth2.client_secret;
9705
+ if (oauth22.client_secret) {
9706
+ params.client_secret = oauth22.client_secret;
9693
9707
  }
9694
- if (oauth2.scope) {
9695
- params.scope = oauth2.scope;
9708
+ if (oauth22.scope) {
9709
+ params.scope = oauth22.scope;
9696
9710
  }
9697
9711
  switch (params.grant_type) {
9698
9712
  case "authorization_code":
9699
- params.redirect_uri = oauth2.redirect_uri;
9713
+ params.redirect_uri = oauth22.redirect_uri;
9700
9714
  params.code = options.tokens.get("authorization_code");
9701
9715
  const code_verifier = options.tokens.get("code_verifier");
9702
9716
  if (code_verifier) {
@@ -9773,6 +9787,277 @@
9773
9787
  }
9774
9788
  return true;
9775
9789
  }
9790
+ function isAuthorized(tokens) {
9791
+ if (typeof tokens == "string") {
9792
+ tokens = tokenStore(tokens).tokens;
9793
+ }
9794
+ let accessToken = tokens.get("access_token");
9795
+ if (accessToken && !isExpired(accessToken)) {
9796
+ return true;
9797
+ }
9798
+ let refreshToken = tokens.get("refresh_token");
9799
+ if (refreshToken) {
9800
+ return true;
9801
+ }
9802
+ return false;
9803
+ }
9804
+
9805
+ // node_modules/@muze-nl/metro-oauth2/src/oauth2.mockserver.mjs
9806
+ var oauth2_mockserver_exports = {};
9807
+ __export(oauth2_mockserver_exports, {
9808
+ default: () => oauth2mockserver
9809
+ });
9810
+ var baseResponse = {
9811
+ status: 200,
9812
+ statusText: "OK",
9813
+ headers: {
9814
+ "Content-Type": "application/json"
9815
+ }
9816
+ };
9817
+ var badRequest = (error3) => {
9818
+ return {
9819
+ status: 400,
9820
+ statusText: "Bad Request",
9821
+ headers: {
9822
+ "Content-Type": "application/json"
9823
+ },
9824
+ body: JSON.stringify({
9825
+ error: "invalid_request",
9826
+ error_description: error3
9827
+ })
9828
+ };
9829
+ };
9830
+ var error2;
9831
+ var pkce = {};
9832
+ function oauth2mockserver(options = {}) {
9833
+ const defaultOptions = {
9834
+ "PKCE": false,
9835
+ "DPoP": false
9836
+ };
9837
+ options = Object.assign({}, defaultOptions, options);
9838
+ return async (req, next) => {
9839
+ let url2 = everything_default.url(req.url);
9840
+ switch (url2.pathname) {
9841
+ case "/authorize/":
9842
+ if (error2 = fails(url2.searchParams, {
9843
+ response_type: "code",
9844
+ client_id: "mockClientId",
9845
+ state: Optional(/.*/)
9846
+ })) {
9847
+ return everything_default.response(badRequest(error2));
9848
+ }
9849
+ if (url2.searchParams.has("code_challenge")) {
9850
+ if (!url2.searchParams.has("code_challenge_method")) {
9851
+ return everything_default.response(badRequest("missing code_challenge_method"));
9852
+ }
9853
+ pkce.code_challenge = url2.searchParams.get("code_challenge");
9854
+ pkce.code_challenge_method = url2.searchParams.get("code_challenge_method");
9855
+ }
9856
+ return everything_default.response(baseResponse, {
9857
+ body: JSON.stringify({
9858
+ code: "mockAuthorizeToken",
9859
+ state: url2.searchParams.get("state")
9860
+ })
9861
+ });
9862
+ break;
9863
+ case "/token/":
9864
+ if (req.data instanceof URLSearchParams) {
9865
+ let body = {};
9866
+ req.data.forEach((value, key) => body[key] = value);
9867
+ req = req.with({ body });
9868
+ }
9869
+ if (error2 = fails(req, {
9870
+ method: "POST",
9871
+ data: {
9872
+ grant_type: oneOf("refresh_token", "authorization_code")
9873
+ }
9874
+ })) {
9875
+ return everything_default.response(badRequest(error2));
9876
+ }
9877
+ switch (req.data.grant_type) {
9878
+ case "refresh_token":
9879
+ if (error2 = fails(req.data, oneOf({
9880
+ refresh_token: "mockRefreshToken",
9881
+ client_id: "mockClientId",
9882
+ client_secret: "mockClientSecret"
9883
+ }, {
9884
+ refresh_token: "mockRefreshToken",
9885
+ client_id: "mockClientId",
9886
+ code_verifier: /.+/
9887
+ }))) {
9888
+ return everything_default.response(badRequest(error2));
9889
+ }
9890
+ break;
9891
+ case "access_token":
9892
+ if (error2 = fails(req.data, oneOf({
9893
+ client_id: "mockClientId",
9894
+ client_secret: "mockClientSecret"
9895
+ }, {
9896
+ client_id: "mockClientId",
9897
+ code_challenge: /.*/,
9898
+ //FIXME: check that this matches code_verifier
9899
+ code_challenge_method: "S256"
9900
+ }))) {
9901
+ return everything_default.response(badRequest(error2));
9902
+ }
9903
+ break;
9904
+ }
9905
+ return everything_default.response(baseResponse, {
9906
+ body: JSON.stringify({
9907
+ access_token: "mockAccessToken",
9908
+ token_type: "mockExample",
9909
+ expires_in: 3600,
9910
+ refresh_token: "mockRefreshToken",
9911
+ example_parameter: "mockExampleValue"
9912
+ })
9913
+ });
9914
+ break;
9915
+ case "/protected/":
9916
+ let auth = req.headers.get("Authorization");
9917
+ let [type, token] = auth ? auth.split(" ") : [];
9918
+ if (!token || token !== "mockAccessToken") {
9919
+ return everything_default.response({
9920
+ status: 401,
9921
+ statusText: "Forbidden",
9922
+ body: "401 Forbidden"
9923
+ });
9924
+ }
9925
+ return everything_default.response(baseResponse, {
9926
+ body: JSON.stringify({
9927
+ result: "Success"
9928
+ })
9929
+ });
9930
+ break;
9931
+ case "/public/":
9932
+ return everything_default.response(baseResponse, {
9933
+ body: JSON.stringify({
9934
+ result: "Success"
9935
+ })
9936
+ });
9937
+ break;
9938
+ default:
9939
+ return everything_default.response({
9940
+ status: 404,
9941
+ statusText: "not found",
9942
+ body: "404 Not Found " + url2
9943
+ });
9944
+ break;
9945
+ }
9946
+ };
9947
+ }
9948
+
9949
+ // node_modules/@muze-nl/metro-oauth2/src/oauth2.discovery.mjs
9950
+ var oauth2_discovery_exports = {};
9951
+ __export(oauth2_discovery_exports, {
9952
+ default: () => makeClient
9953
+ });
9954
+ var validAlgorithms = [
9955
+ "HS256",
9956
+ "HS384",
9957
+ "HS512",
9958
+ "RS256",
9959
+ "RS384",
9960
+ "RS512",
9961
+ "ES256",
9962
+ "ES384",
9963
+ "ES512"
9964
+ ];
9965
+ var validAuthMethods = [
9966
+ "client_secret_post",
9967
+ "client_secret_base",
9968
+ "client_secret_jwt",
9969
+ "private_key_jwt"
9970
+ ];
9971
+ var oauth_authorization_server_metadata = {
9972
+ issuer: Required(validURL),
9973
+ authorization_endpoint: Required(validURL),
9974
+ token_endpoint: Required(validURL),
9975
+ jwks_uri: Optional(validURL),
9976
+ registration_endpoint: Optional(validURL),
9977
+ scopes_supported: Recommended([]),
9978
+ response_types_supported: Required(anyOf("code", "token")),
9979
+ response_modes_supported: Optional([]),
9980
+ grant_types_supported: Optional([]),
9981
+ token_endpoint_auth_methods_supported: Optional([]),
9982
+ token_endpoint_auth_signing_alg_values_supported: Optional([]),
9983
+ service_documentation: Optional(validURL),
9984
+ ui_locales_supported: Optional([]),
9985
+ op_policy_uri: Optional(validURL),
9986
+ op_tos_uri: Optional(validURL),
9987
+ revocation_endpoint: Optional(validURL),
9988
+ revocation_endpoint_auth_methods_supported: Optional(validAuthMethods),
9989
+ revocation_endpoint_auth_signing_alg_values_supported: Optional(validAlgorithms),
9990
+ introspection_endpoint: Optional(validURL),
9991
+ introspection_endpoint_auth_methods_supported: Optional(validAuthMethods),
9992
+ introspection_endpoint_auth_signing_alg_values_supported: Optional(validAlgorithms),
9993
+ code_challendge_methods_supported: Optional([])
9994
+ };
9995
+ function makeClient(options = {}) {
9996
+ const defaultOptions = {
9997
+ client: everything_default.client()
9998
+ };
9999
+ options = Object.assign({}, defaultOptions, options);
10000
+ assert(options, {
10001
+ issuer: Required(validURL)
10002
+ });
10003
+ const oauth_authorization_server_configuration = fetchWellknownOauthAuthorizationServer(options.issuer);
10004
+ return options.client.with(options.issuer);
10005
+ }
10006
+ async function fetchWellknownOauthAuthorizationServer(issuer, client2) {
10007
+ let res = client2.get(everything_default.url(issuer, ".wellknown/oauth_authorization_server"));
10008
+ if (res.ok) {
10009
+ assert(res.headers.get("Content-Type"), /application\/json.*/);
10010
+ let configuration = await res.json();
10011
+ assert(configuration, oauth_authorization_server_metadata);
10012
+ return configuration;
10013
+ }
10014
+ throw everything_default.metroError("metro.oidcmw: Error while fetching " + issuer + ".wellknown/oauth_authorization_server", res);
10015
+ }
10016
+
10017
+ // node_modules/@muze-nl/metro-oauth2/src/oauth2.popup.mjs
10018
+ function handleRedirect(origin = null) {
10019
+ let success = false;
10020
+ origin = origin || window.location.origin;
10021
+ let params = new URLSearchParams(window.location.search);
10022
+ if (!params.has("code") && window.location.hash) {
10023
+ let query = window.location.hash.substr(1);
10024
+ params = new URLSearchParams("?" + query);
10025
+ }
10026
+ let parent = window.parent !== window ? window.parent : window.opener;
10027
+ if (!parent) {
10028
+ console.error("No parent window found, cannot post authorization code (or error)");
10029
+ } else {
10030
+ if (params.has("code")) {
10031
+ parent.postMessage({
10032
+ authorization_code: params.get("code")
10033
+ }, origin);
10034
+ success = true;
10035
+ } else if (params.has("error")) {
10036
+ parent.postMessage({
10037
+ error: params.get("error")
10038
+ }, origin);
10039
+ } else {
10040
+ parent.postMessage({
10041
+ error: "Could not find an authorization_code"
10042
+ }, origin);
10043
+ }
10044
+ }
10045
+ return success;
10046
+ }
10047
+ function authorizePopup(authorizationCodeURL) {
10048
+ return new Promise((resolve, reject) => {
10049
+ addEventListener("message", (event) => {
10050
+ if (event.data.authorization_code) {
10051
+ resolve(event.data.authorization_code);
10052
+ } else if (event.data.error) {
10053
+ reject(event.data.error);
10054
+ } else {
10055
+ reject("Unknown authorization error");
10056
+ }
10057
+ }, { once: true });
10058
+ window.open(authorizationCodeURL);
10059
+ });
10060
+ }
9776
10061
 
9777
10062
  // node_modules/@muze-nl/metro-oauth2/src/keysstore.mjs
9778
10063
  function keysStore() {
@@ -10085,6 +10370,21 @@
10085
10370
  };
10086
10371
  }
10087
10372
 
10373
+ // node_modules/@muze-nl/metro-oauth2/src/browser.mjs
10374
+ var oauth2 = Object.assign({}, oauth2_exports, {
10375
+ oauth2mw,
10376
+ mockserver: oauth2_mockserver_exports,
10377
+ discover: oauth2_discovery_exports,
10378
+ tokenstore: tokenStore,
10379
+ dpopmw,
10380
+ keysstore: keysStore,
10381
+ authorizePopup,
10382
+ popupHandleRedirect: handleRedirect
10383
+ });
10384
+ if (!globalThis.metro.oauth2) {
10385
+ globalThis.metro.oauth2 = oauth2;
10386
+ }
10387
+
10088
10388
  // node_modules/@muze-nl/metro-oidc/src/oidc.util.mjs
10089
10389
  var MustHave = (...options) => (value, root) => {
10090
10390
  if (options.filter((o) => root.hasOwnKey(o)).length > 0) {
@@ -10110,7 +10410,7 @@
10110
10410
  "ES384",
10111
10411
  "ES512"
10112
10412
  ];
10113
- var validAuthMethods = [
10413
+ var validAuthMethods2 = [
10114
10414
  "client_secret_post",
10115
10415
  "client_secret_basic",
10116
10416
  "client_secret_jwt",
@@ -10156,7 +10456,7 @@
10156
10456
  // not testing for 'none'
10157
10457
  request_object_encryption_alg_values_supported: Optional([]),
10158
10458
  request_object_encryption_enc_values_supported: Optional([]),
10159
- token_endpoint_auth_methods_supported: Optional(anyOf(...validAuthMethods)),
10459
+ token_endpoint_auth_methods_supported: Optional(anyOf(...validAuthMethods2)),
10160
10460
  token_endpoint_auth_signing_alg_values_supported: Optional(MustInclude("RS256"), not(MustInclude("none"))),
10161
10461
  display_values_supported: Optional(anyOf("page", "popup", "touch", "wap")),
10162
10462
  claim_types_supported: Optional(anyOf("normal", "aggregated", "distributed")),
@@ -10209,7 +10509,7 @@
10209
10509
  request_object_signing_alg: Optional(oneOf(...validJWA)),
10210
10510
  request_object_encryption_alg: Optional(oneOf(...validJWA)),
10211
10511
  request_object_encryption_enc: Optional(oneOf(...validJWA)),
10212
- token_endpoint_auth_method: Optional(oneOf(...validAuthMethods)),
10512
+ token_endpoint_auth_method: Optional(oneOf(...validAuthMethods2)),
10213
10513
  token_endpoint_auth_signing_alg: Optional(oneOf(...validJWA)),
10214
10514
  default_max_age: Optional(Number),
10215
10515
  require_auth_time: Optional(Boolean),
@@ -10238,11 +10538,11 @@
10238
10538
  let response2 = await options.client.post(options.registration_endpoint, {
10239
10539
  body: options.client_info
10240
10540
  });
10241
- let info = response2.data;
10242
- if (!info.client_id || !info.client_secret) {
10541
+ let info2 = response2.data;
10542
+ if (!info2.client_id || !info2.client_secret) {
10243
10543
  throw everything_default.metroError("metro.oidc: Error: dynamic registration of client failed, no client_id or client_secret returned", response2);
10244
10544
  }
10245
- options.client_info = Object.assign(options.client_info, info);
10545
+ options.client_info = Object.assign(options.client_info, info2);
10246
10546
  return options.client_info;
10247
10547
  }
10248
10548
 
@@ -10267,7 +10567,7 @@
10267
10567
  }
10268
10568
 
10269
10569
  // node_modules/@muze-nl/metro-oidc/src/oidcmw.mjs
10270
- function oidcmw(options = {}) {
10570
+ function oidcmw2(options = {}) {
10271
10571
  const defaultOptions = {
10272
10572
  client: client(),
10273
10573
  force_authorization: false,
@@ -10401,7 +10701,7 @@
10401
10701
 
10402
10702
  // node_modules/@muze-nl/metro-oidc/src/browser.mjs
10403
10703
  var oidc = {
10404
- oidcmw,
10704
+ oidcmw: oidcmw2,
10405
10705
  discover: oidcDiscovery,
10406
10706
  register,
10407
10707
  isRedirected: isRedirected2,
@@ -10410,10 +10710,10 @@
10410
10710
  if (!globalThis.metro.oidc) {
10411
10711
  globalThis.metro.oidc = oidc;
10412
10712
  }
10413
- var browser_default = oidc;
10713
+ var browser_default2 = oidc;
10414
10714
 
10415
10715
  // node_modules/@muze-nl/oldm/src/oldm.mjs
10416
- function oldm(options) {
10716
+ function oldm2(options) {
10417
10717
  return new Context(options);
10418
10718
  }
10419
10719
  var rdfType = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
@@ -10684,8 +10984,8 @@
10684
10984
  // node_modules/@muze-nl/oldm/src/oldm-n3.mjs
10685
10985
  var oldm_n3_exports = {};
10686
10986
  __export(oldm_n3_exports, {
10687
- n3Parser: () => n3Parser,
10688
- n3Writer: () => n3Writer
10987
+ n3Parser: () => n3Parser2,
10988
+ n3Writer: () => n3Writer2
10689
10989
  });
10690
10990
 
10691
10991
  // node_modules/n3/src/N3Lexer.js
@@ -11127,9 +11427,9 @@
11127
11427
  queueMicrotask(() => this._tokenizeToEnd(callback, true));
11128
11428
  else {
11129
11429
  const tokens = [];
11130
- let error2;
11131
- this._tokenizeToEnd((e, t) => e ? error2 = e : tokens.push(t), true);
11132
- if (error2) throw error2;
11430
+ let error3;
11431
+ this._tokenizeToEnd((e, t) => e ? error3 = e : tokens.push(t), true);
11432
+ if (error3) throw error3;
11133
11433
  return tokens;
11134
11434
  }
11135
11435
  } else {
@@ -12516,27 +12816,27 @@
12516
12816
  this._quantified = /* @__PURE__ */ Object.create(null);
12517
12817
  if (!onQuad) {
12518
12818
  const quads = [];
12519
- let error2;
12819
+ let error3;
12520
12820
  this._callback = (e, t) => {
12521
- e ? error2 = e : t && quads.push(t);
12821
+ e ? error3 = e : t && quads.push(t);
12522
12822
  };
12523
12823
  this._lexer.tokenize(input).every((token) => {
12524
12824
  return this._readCallback = this._readCallback(token);
12525
12825
  });
12526
- if (error2) throw error2;
12826
+ if (error3) throw error3;
12527
12827
  return quads;
12528
12828
  }
12529
- let processNextToken = (error2, token) => {
12530
- if (error2 !== null)
12531
- this._callback(error2), this._callback = noop;
12829
+ let processNextToken = (error3, token) => {
12830
+ if (error3 !== null)
12831
+ this._callback(error3), this._callback = noop;
12532
12832
  else if (this._readCallback)
12533
12833
  this._readCallback = this._readCallback(token);
12534
12834
  };
12535
12835
  if (onComment) {
12536
12836
  this._lexer.comments = true;
12537
- processNextToken = (error2, token) => {
12538
- if (error2 !== null)
12539
- this._callback(error2), this._callback = noop;
12837
+ processNextToken = (error3, token) => {
12838
+ if (error3 !== null)
12839
+ this._callback(error3), this._callback = noop;
12540
12840
  else if (this._readCallback) {
12541
12841
  if (token.type === "comment")
12542
12842
  onComment(token.value);
@@ -12792,8 +13092,8 @@
12792
13092
  ${this._encodePredicate(this._predicate = predicate)} ${this._encodeObject(object)}`, done);
12793
13093
  } else
12794
13094
  this._write(`${(this._subject === null ? "" : ".\n") + this._encodeSubject(this._subject = subject)} ${this._encodePredicate(this._predicate = predicate)} ${this._encodeObject(object)}`, done);
12795
- } catch (error2) {
12796
- done && done(error2);
13095
+ } catch (error3) {
13096
+ done && done(error3);
12797
13097
  }
12798
13098
  }
12799
13099
  // ### `_writeQuadLine` writes the quad to the output stream as a single line
@@ -12988,13 +13288,13 @@
12988
13288
  this._subject = null;
12989
13289
  }
12990
13290
  this._write = this._blockedWrite;
12991
- let singleDone = done && ((error2, result2) => {
12992
- singleDone = null, done(error2, result2);
13291
+ let singleDone = done && ((error3, result2) => {
13292
+ singleDone = null, done(error3, result2);
12993
13293
  });
12994
13294
  if (this._endStream) {
12995
13295
  try {
12996
13296
  return this._outputStream.end(singleDone);
12997
- } catch (error2) {
13297
+ } catch (error3) {
12998
13298
  }
12999
13299
  }
13000
13300
  singleDone && singleDone();
@@ -14207,8 +14507,8 @@
14207
14507
  let onData, onEnd;
14208
14508
  const callbacks = {
14209
14509
  // Handle quads by pushing them down the pipeline
14210
- onQuad: (error2, quad2) => {
14211
- error2 && this.emit("error", error2) || quad2 && this.push(quad2);
14510
+ onQuad: (error3, quad2) => {
14511
+ error3 && this.emit("error", error3) || quad2 && this.push(quad2);
14212
14512
  },
14213
14513
  // Emit prefixes through the `prefix` event
14214
14514
  onPrefix: (prefix2, uri) => {
@@ -14248,8 +14548,8 @@
14248
14548
  stream.on("end", () => {
14249
14549
  this.end();
14250
14550
  });
14251
- stream.on("error", (error2) => {
14252
- this.emit("error", error2);
14551
+ stream.on("error", (error3) => {
14552
+ this.emit("error", error3);
14253
14553
  });
14254
14554
  return this;
14255
14555
  }
@@ -14285,8 +14585,8 @@
14285
14585
  stream.on("end", () => {
14286
14586
  this.end();
14287
14587
  });
14288
- stream.on("error", (error2) => {
14289
- this.emit("error", error2);
14588
+ stream.on("error", (error3) => {
14589
+ this.emit("error", error3);
14290
14590
  });
14291
14591
  stream.on("prefix", (prefix2, iri) => {
14292
14592
  this._writer.addPrefix(prefix2, iri);
@@ -14322,7 +14622,7 @@
14322
14622
  };
14323
14623
 
14324
14624
  // node_modules/@muze-nl/oldm/src/oldm-n3.mjs
14325
- var n3Parser = (input, uri, type) => {
14625
+ var n3Parser2 = (input, uri, type) => {
14326
14626
  const parser = new src_default.Parser({
14327
14627
  baseIRI: uri,
14328
14628
  blankNodePrefix: "",
@@ -14334,7 +14634,7 @@
14334
14634
  });
14335
14635
  return { quads, prefixes: prefixes3 };
14336
14636
  };
14337
- var n3Writer = (source) => {
14637
+ var n3Writer2 = (source) => {
14338
14638
  return new Promise((resolve, reject) => {
14339
14639
  const writer = new src_default.Writer({
14340
14640
  format: source.type,
@@ -14466,23 +14766,23 @@
14466
14766
  writeClassNames(id, subject);
14467
14767
  writeProperties(id, subject);
14468
14768
  });
14469
- writer.end((error2, result2) => {
14769
+ writer.end((error3, result2) => {
14470
14770
  if (result2) {
14471
14771
  resolve(result2);
14472
14772
  } else {
14473
- reject(error2);
14773
+ reject(error3);
14474
14774
  }
14475
14775
  });
14476
14776
  });
14477
14777
  };
14478
14778
 
14479
14779
  // node_modules/@muze-nl/oldm/src/index.mjs
14480
- var oldm2 = {
14481
- context: oldm,
14780
+ var oldm3 = {
14781
+ context: oldm2,
14482
14782
  ...oldm_n3_exports
14483
14783
  };
14484
- globalThis.oldm = oldm2;
14485
- var src_default2 = oldm2;
14784
+ globalThis.oldm = oldm3;
14785
+ var src_default2 = oldm3;
14486
14786
 
14487
14787
  // node_modules/@muze-nl/jaqt/src/jaqt.mjs
14488
14788
  function isPrimitiveWrapper(data) {
@@ -14934,7 +15234,7 @@
14934
15234
  var _ = new Proxy(getPointerFn(), pointerHandler());
14935
15235
 
14936
15236
  // node_modules/@muze-nl/metro-oldm/src/oldmmw.mjs
14937
- function oldmmw(options) {
15237
+ function oldmmw2(options) {
14938
15238
  options = Object.assign({
14939
15239
  contentType: "text/turtle",
14940
15240
  prefixes: {
@@ -14957,7 +15257,7 @@
14957
15257
  options.prefixes["ldp"] = "http://www.w3.org/ns/ldp#";
14958
15258
  }
14959
15259
  const context = src_default2.context(options);
14960
- return async function oldmmw2(req, next) {
15260
+ return async function oldmmw3(req, next) {
14961
15261
  if (!req.headers.get("Accept")) {
14962
15262
  req = req.with({
14963
15263
  headers: {
@@ -15014,15 +15314,15 @@
15014
15314
  }
15015
15315
 
15016
15316
  // node_modules/@muze-nl/metro-oldm/src/index.mjs
15017
- globalThis.oldmmw = oldmmw;
15018
- var src_default3 = oldmmw;
15317
+ globalThis.oldmmw = oldmmw2;
15318
+ var src_default3 = oldmmw2;
15019
15319
 
15020
15320
  // src/SolidAdapter.js
15021
15321
  var SolidAdapter = class extends HttpAdapter {
15022
15322
  #client;
15023
15323
  #path;
15024
15324
  constructor(metroClient, path = "/", solidConfiguration = {}) {
15025
- metroClient = client(metroClient).with(browser_default.oidcmw(solidConfiguration)).with(src_default3(solidConfiguration));
15325
+ metroClient = client(metroClient).with(browser_default2.oidcmw(solidConfiguration)).with(src_default3(solidConfiguration));
15026
15326
  path = Path.collapse(path);
15027
15327
  super(metroClient, path);
15028
15328
  this.#client = metroClient;
@@ -15031,6 +15331,9 @@
15031
15331
  get name() {
15032
15332
  return "SolidAdapter";
15033
15333
  }
15334
+ supportsDirectories() {
15335
+ return true;
15336
+ }
15034
15337
  async read(path) {
15035
15338
  let response2 = await this.#client.get(Path.collapse(path, this.#path));
15036
15339
  let result2 = {
@@ -15071,15 +15374,61 @@
15071
15374
  throw new Error(path + " could not be parsed", { cause: result2 });
15072
15375
  }
15073
15376
  }
15377
+ async mkdir(path) {
15378
+ this.#client.put(Path.collapse(path, this.#path));
15379
+ }
15380
+ async rmdir(path) {
15381
+ this.#client.delete(Path.collapse(path, this.#path));
15382
+ }
15074
15383
  };
15075
15384
 
15076
15385
  // src/SolidClient.js
15077
- function solidClient(...options) {
15078
- return new jsfs.fs(new SolidAdapter(...options));
15386
+ async function solidClient(webid, solidOptions) {
15387
+ const defaults = {
15388
+ prefixes: {
15389
+ "ldp": "http://www.w3.org/ns/ldp#",
15390
+ "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
15391
+ "dct": "http://purl.org/dc/terms/",
15392
+ "stat": "http://www.w3.org/ns/posix/stat#",
15393
+ "turtle": "http://www.w3.org/ns/iana/media-types/text/turtle#",
15394
+ "schema": "https://schema.org/",
15395
+ "solid": "http://www.w3.org/ns/solid/terms#",
15396
+ "acl": "http://www.w3.org/ns/auth/acl#",
15397
+ "space": "http://www.w3.org/ns/pim/space#",
15398
+ "vcard": "http://www.w3.org/2006/vcard/ns#",
15399
+ "foaf": "http://xmlns.com/foaf/0.1/"
15400
+ },
15401
+ parser: n3Parser,
15402
+ writer: n3Writer
15403
+ };
15404
+ const options = Object.assign({}, defaults, solidOptions);
15405
+ for (const prefix2 in defaults.prefixes) {
15406
+ if (!info.prefixes[prefix2]) {
15407
+ info.prefixes[prefix2] = defaults.prefixes[prefix2];
15408
+ }
15409
+ }
15410
+ const profile = await metro.client().with(oldmmw(info), getdatamw()).get(webid)?.primary;
15411
+ if (!profile || !profile.solid$oidcIssuer) {
15412
+ throw new Error("solidClient: " + webid + " did not return valid solid profile");
15413
+ }
15414
+ info.issuer = profile.solid$oidcIssuer;
15415
+ const storage = oldm.many(profile.space$storage).map((s) => new jsfs.fs(new SolidAdapter(s, "/", info)));
15416
+ return metro.api(
15417
+ metro.client(oidcmw(info), oldmmw(info)),
15418
+ {
15419
+ profile,
15420
+ issuer: profile.solid$oidcIssuer,
15421
+ inbox: profile.ldp$inbox,
15422
+ id: function() {
15423
+ return metro.oidc.idToken(this.issuer);
15424
+ },
15425
+ logout: async function() {
15426
+ throw new Error("not yet implemented");
15427
+ },
15428
+ ...storage
15429
+ }
15430
+ );
15079
15431
  }
15080
- var SolidClient_default = SolidAdapter;
15081
- globalThis.solidClient = solidClient;
15082
- globalThis.SolidAdapter = SolidAdapter;
15083
15432
  })();
15084
15433
  /*! Bundled license information:
15085
15434