solid-ui 2.4.25-3d353685 → 2.4.25-e709d181

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/main.js CHANGED
@@ -13119,12 +13119,12 @@ Object.defineProperty(exports, "__esModule", ({
13119
13119
  }));
13120
13120
  exports.versionInfo = void 0;
13121
13121
  var versionInfo = {
13122
- buildTime: '2023-02-13T18:33:53Z',
13123
- commit: '3d3536854bc96f1a76b3da3788eb578207ead433',
13122
+ buildTime: '2023-03-02T16:37:54Z',
13123
+ commit: 'e709d1818c38b016f4032b30613ee30fdcc12dc3',
13124
13124
  npmInfo: {
13125
13125
  'solid-ui': '2.4.25',
13126
13126
  npm: '8.19.3',
13127
- node: '16.19.0',
13127
+ node: '16.19.1',
13128
13128
  v8: '9.4.146.26-node.24',
13129
13129
  uv: '1.43.0',
13130
13130
  zlib: '1.2.11',
@@ -13134,7 +13134,7 @@ var versionInfo = {
13134
13134
  nghttp2: '1.47.0',
13135
13135
  napi: '8',
13136
13136
  llhttp: '6.0.10',
13137
- openssl: '1.1.1s+quic',
13137
+ openssl: '1.1.1t+quic',
13138
13138
  cldr: '41.0',
13139
13139
  icu: '71.1',
13140
13140
  tz: '2022f',
@@ -25646,7 +25646,10 @@ class ClientAuthentication {
25646
25646
  this.login = async (options, eventEmitter) => {
25647
25647
  var _a, _b;
25648
25648
  await this.sessionInfoManager.clear(options.sessionId);
25649
- const redirectUrl = (0, oidc_client_ext_1.removeOidcQueryParam)((_a = options.redirectUrl) !== null && _a !== void 0 ? _a : window.location.href);
25649
+ const redirectUrl = (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : (0, oidc_client_ext_1.removeOidcQueryParam)(window.location.href);
25650
+ if (!(0, solid_client_authn_core_1.isValidRedirectUrl)(redirectUrl)) {
25651
+ throw new Error(`${redirectUrl} is not a valid redirect URL, it is either a malformed IRI or it includes a hash fragment.`);
25652
+ }
25650
25653
  await this.loginHandler.handle({
25651
25654
  ...options,
25652
25655
  redirectUrl,
@@ -26117,7 +26120,6 @@ exports["default"] = ClientRegistrar;
26117
26120
  Object.defineProperty(exports, "__esModule", ({ value: true }));
26118
26121
  exports.WELL_KNOWN_OPENID_CONFIG = void 0;
26119
26122
  const solid_client_authn_core_1 = __webpack_require__(/*! @inrupt/solid-client-authn-core */ "./node_modules/@inrupt/solid-client-authn-core/dist/index.js");
26120
- const urlPath_1 = __webpack_require__(/*! ../../util/urlPath */ "./node_modules/@inrupt/solid-client-authn-browser/dist/util/urlPath.js");
26121
26123
  exports.WELL_KNOWN_OPENID_CONFIG = ".well-known/openid-configuration";
26122
26124
  const issuerConfigKeyMap = {
26123
26125
  issuer: {
@@ -26223,7 +26225,7 @@ class IssuerConfigFetcher {
26223
26225
  }
26224
26226
  async fetchConfig(issuer) {
26225
26227
  let issuerConfig;
26226
- const openIdConfigUrl = (0, urlPath_1.appendToUrlPathname)(issuer, exports.WELL_KNOWN_OPENID_CONFIG);
26228
+ const openIdConfigUrl = new URL(exports.WELL_KNOWN_OPENID_CONFIG, issuer).href;
26227
26229
  const issuerConfigRequestBody = await window.fetch(openIdConfigUrl);
26228
26230
  try {
26229
26231
  issuerConfig = processConfig(await issuerConfigRequestBody.json());
@@ -26774,27 +26776,6 @@ exports["default"] = StorageUtilityBrowser;
26774
26776
 
26775
26777
  /***/ }),
26776
26778
 
26777
- /***/ "./node_modules/@inrupt/solid-client-authn-browser/dist/util/urlPath.js":
26778
- /*!******************************************************************************!*\
26779
- !*** ./node_modules/@inrupt/solid-client-authn-browser/dist/util/urlPath.js ***!
26780
- \******************************************************************************/
26781
- /***/ ((__unused_webpack_module, exports) => {
26782
-
26783
- "use strict";
26784
-
26785
- Object.defineProperty(exports, "__esModule", ({ value: true }));
26786
- exports.appendToUrlPathname = void 0;
26787
- function appendToUrlPathname(url, append) {
26788
- const parsedUrl = new URL(url);
26789
- const path = parsedUrl.pathname;
26790
- parsedUrl.pathname = `${path}${path.endsWith("/") ? "" : "/"}${append.startsWith("/") ? append.substring(1) : append}`;
26791
- return parsedUrl.toString();
26792
- }
26793
- exports.appendToUrlPathname = appendToUrlPathname;
26794
- //# sourceMappingURL=urlPath.js.map
26795
-
26796
- /***/ }),
26797
-
26798
26779
  /***/ "./node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/commonjs-browser/index.js":
26799
26780
  /*!**********************************************************************************************************!*\
26800
26781
  !*** ./node_modules/@inrupt/solid-client-authn-browser/node_modules/uuid/dist/commonjs-browser/index.js ***!
@@ -27909,6 +27890,16 @@ async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
27909
27890
  }
27910
27891
  }
27911
27892
 
27893
+ function isValidRedirectUrl(redirectUrl) {
27894
+ try {
27895
+ const urlObject = new URL(redirectUrl);
27896
+ return urlObject.hash === "";
27897
+ }
27898
+ catch (e) {
27899
+ return false;
27900
+ }
27901
+ }
27902
+
27912
27903
  function isSupportedTokenType(token) {
27913
27904
  return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
27914
27905
  }
@@ -28324,6 +28315,7 @@ exports.getSessionIdFromOauthState = getSessionIdFromOauthState;
28324
28315
  exports.getWebidFromTokenPayload = getWebidFromTokenPayload;
28325
28316
  exports.handleRegistration = handleRegistration;
28326
28317
  exports.isSupportedTokenType = isSupportedTokenType;
28318
+ exports.isValidRedirectUrl = isValidRedirectUrl;
28327
28319
  exports.loadOidcContextFromStorage = loadOidcContextFromStorage;
28328
28320
  exports.mockStorage = mockStorage;
28329
28321
  exports.mockStorageUtility = mockStorageUtility;
@@ -35244,6 +35236,7 @@ const {
35244
35236
  } = __webpack_require__(/*! ./url */ "./node_modules/jsonld/lib/url.js");
35245
35237
 
35246
35238
  const {
35239
+ REGEX_KEYWORD,
35247
35240
  addValue: _addValue,
35248
35241
  asArray: _asArray,
35249
35242
  compareShortestLeast: _compareShortestLeast
@@ -35261,7 +35254,6 @@ module.exports = api;
35261
35254
  * to compact, null for none.
35262
35255
  * @param element the element to compact.
35263
35256
  * @param options the compaction options.
35264
- * @param compactionMap the compaction map to use.
35265
35257
  *
35266
35258
  * @return a promise that resolves to the compacted value.
35267
35259
  */
@@ -35269,33 +35261,21 @@ api.compact = async ({
35269
35261
  activeCtx,
35270
35262
  activeProperty = null,
35271
35263
  element,
35272
- options = {},
35273
- compactionMap = () => undefined
35264
+ options = {}
35274
35265
  }) => {
35275
35266
  // recursively compact array
35276
35267
  if(_isArray(element)) {
35277
35268
  let rval = [];
35278
35269
  for(let i = 0; i < element.length; ++i) {
35279
- // compact, dropping any null values unless custom mapped
35280
- let compacted = await api.compact({
35270
+ const compacted = await api.compact({
35281
35271
  activeCtx,
35282
35272
  activeProperty,
35283
35273
  element: element[i],
35284
- options,
35285
- compactionMap
35274
+ options
35286
35275
  });
35287
35276
  if(compacted === null) {
35288
- compacted = await compactionMap({
35289
- unmappedValue: element[i],
35290
- activeCtx,
35291
- activeProperty,
35292
- parent: element,
35293
- index: i,
35294
- options
35295
- });
35296
- if(compacted === undefined) {
35297
- continue;
35298
- }
35277
+ // FIXME: need event?
35278
+ continue;
35299
35279
  }
35300
35280
  rval.push(compacted);
35301
35281
  }
@@ -35359,8 +35339,7 @@ api.compact = async ({
35359
35339
  activeCtx,
35360
35340
  activeProperty,
35361
35341
  element: element['@list'],
35362
- options,
35363
- compactionMap
35342
+ options
35364
35343
  });
35365
35344
  }
35366
35345
  }
@@ -35488,8 +35467,7 @@ api.compact = async ({
35488
35467
  activeCtx,
35489
35468
  activeProperty: '@reverse',
35490
35469
  element: expandedValue,
35491
- options,
35492
- compactionMap
35470
+ options
35493
35471
  });
35494
35472
 
35495
35473
  // handle double-reversed properties
@@ -35526,8 +35504,7 @@ api.compact = async ({
35526
35504
  activeCtx,
35527
35505
  activeProperty,
35528
35506
  element: expandedValue,
35529
- options,
35530
- compactionMap
35507
+ options
35531
35508
  });
35532
35509
 
35533
35510
  if(!(_isArray(compactedValue) && compactedValue.length === 0)) {
@@ -35644,8 +35621,7 @@ api.compact = async ({
35644
35621
  activeCtx,
35645
35622
  activeProperty: itemActiveProperty,
35646
35623
  element: (isList || isGraph) ? inner : expandedItem,
35647
- options,
35648
- compactionMap
35624
+ options
35649
35625
  });
35650
35626
 
35651
35627
  // handle @list
@@ -35840,8 +35816,7 @@ api.compact = async ({
35840
35816
  activeCtx,
35841
35817
  activeProperty: itemActiveProperty,
35842
35818
  element: {'@id': expandedItem['@id']},
35843
- options,
35844
- compactionMap
35819
+ options
35845
35820
  });
35846
35821
  }
35847
35822
  }
@@ -36155,7 +36130,8 @@ api.compactIri = ({
36155
36130
  // The None case preserves rval as potentially relative
36156
36131
  return iri;
36157
36132
  } else {
36158
- return _removeBase(_prependBase(base, activeCtx['@base']), iri);
36133
+ const _iri = _removeBase(_prependBase(base, activeCtx['@base']), iri);
36134
+ return REGEX_KEYWORD.test(_iri) ? `./${_iri}` : _iri;
36159
36135
  }
36160
36136
  } else {
36161
36137
  return _removeBase(base, iri);
@@ -36462,13 +36438,18 @@ const {
36462
36438
  } = __webpack_require__(/*! ./url */ "./node_modules/jsonld/lib/url.js");
36463
36439
 
36464
36440
  const {
36441
+ handleEvent: _handleEvent
36442
+ } = __webpack_require__(/*! ./events */ "./node_modules/jsonld/lib/events.js");
36443
+
36444
+ const {
36445
+ REGEX_BCP47,
36446
+ REGEX_KEYWORD,
36465
36447
  asArray: _asArray,
36466
36448
  compareShortestLeast: _compareShortestLeast
36467
36449
  } = __webpack_require__(/*! ./util */ "./node_modules/jsonld/lib/util.js");
36468
36450
 
36469
36451
  const INITIAL_CONTEXT_CACHE = new Map();
36470
36452
  const INITIAL_CONTEXT_CACHE_MAX_SIZE = 10000;
36471
- const KEYWORD_PATTERN = /^@[a-zA-Z]+$/;
36472
36453
 
36473
36454
  const api = {};
36474
36455
  module.exports = api;
@@ -36503,6 +36484,23 @@ api.process = async ({
36503
36484
  return activeCtx;
36504
36485
  }
36505
36486
 
36487
+ // event handler for capturing events to replay when using a cached context
36488
+ const events = [];
36489
+ const eventCaptureHandler = [
36490
+ ({event, next}) => {
36491
+ events.push(event);
36492
+ next();
36493
+ }
36494
+ ];
36495
+ // chain to original handler
36496
+ if(options.eventHandler) {
36497
+ eventCaptureHandler.push(options.eventHandler);
36498
+ }
36499
+ // store original options to use when replaying events
36500
+ const originalOptions = options;
36501
+ // shallow clone options with event capture handler
36502
+ options = {...options, eventHandler: eventCaptureHandler};
36503
+
36506
36504
  // resolve contexts
36507
36505
  const resolved = await options.contextResolver.resolve({
36508
36506
  activeCtx,
@@ -36540,46 +36538,12 @@ api.process = async ({
36540
36538
  if(ctx === null) {
36541
36539
  // We can't nullify if there are protected terms and we're
36542
36540
  // not allowing overrides (e.g. processing a property term scoped context)
36543
- if(!overrideProtected &&
36544
- Object.keys(activeCtx.protected).length !== 0) {
36545
- const protectedMode = (options && options.protectedMode) || 'error';
36546
- if(protectedMode === 'error') {
36547
- throw new JsonLdError(
36548
- 'Tried to nullify a context with protected terms outside of ' +
36549
- 'a term definition.',
36550
- 'jsonld.SyntaxError',
36551
- {code: 'invalid context nullification'});
36552
- } else if(protectedMode === 'warn') {
36553
- // FIXME: remove logging and use a handler
36554
- console.warn('WARNING: invalid context nullification');
36555
-
36556
- // get processed context from cache if available
36557
- const processed = resolvedContext.getProcessed(activeCtx);
36558
- if(processed) {
36559
- rval = activeCtx = processed;
36560
- continue;
36561
- }
36562
-
36563
- const oldActiveCtx = activeCtx;
36564
- // copy all protected term definitions to fresh initial context
36565
- rval = activeCtx = api.getInitialContext(options).clone();
36566
- for(const [term, _protected] of
36567
- Object.entries(oldActiveCtx.protected)) {
36568
- if(_protected) {
36569
- activeCtx.mappings[term] =
36570
- util.clone(oldActiveCtx.mappings[term]);
36571
- }
36572
- }
36573
- activeCtx.protected = util.clone(oldActiveCtx.protected);
36574
-
36575
- // cache processed result
36576
- resolvedContext.setProcessed(oldActiveCtx, rval);
36577
- continue;
36578
- }
36541
+ if(!overrideProtected && Object.keys(activeCtx.protected).length !== 0) {
36579
36542
  throw new JsonLdError(
36580
- 'Invalid protectedMode.',
36543
+ 'Tried to nullify a context with protected terms outside of ' +
36544
+ 'a term definition.',
36581
36545
  'jsonld.SyntaxError',
36582
- {code: 'invalid protected mode', context: localCtx, protectedMode});
36546
+ {code: 'invalid context nullification'});
36583
36547
  }
36584
36548
  rval = activeCtx = api.getInitialContext(options).clone();
36585
36549
  continue;
@@ -36588,7 +36552,14 @@ api.process = async ({
36588
36552
  // get processed context from cache if available
36589
36553
  const processed = resolvedContext.getProcessed(activeCtx);
36590
36554
  if(processed) {
36591
- rval = activeCtx = processed;
36555
+ if(originalOptions.eventHandler) {
36556
+ // replay events with original non-capturing options
36557
+ for(const event of processed.events) {
36558
+ _handleEvent({event, options: originalOptions});
36559
+ }
36560
+ }
36561
+
36562
+ rval = activeCtx = processed.context;
36592
36563
  continue;
36593
36564
  }
36594
36565
 
@@ -36673,8 +36644,25 @@ api.process = async ({
36673
36644
  '@context must be an absolute IRI.',
36674
36645
  'jsonld.SyntaxError', {code: 'invalid vocab mapping', context: ctx});
36675
36646
  } else {
36676
- rval['@vocab'] = _expandIri(rval, value, {vocab: true, base: true},
36647
+ const vocab = _expandIri(rval, value, {vocab: true, base: true},
36677
36648
  undefined, undefined, options);
36649
+ if(!_isAbsoluteIri(vocab)) {
36650
+ if(options.eventHandler) {
36651
+ _handleEvent({
36652
+ event: {
36653
+ type: ['JsonLdEvent'],
36654
+ code: 'relative @vocab reference',
36655
+ level: 'warning',
36656
+ message: 'Relative @vocab reference found.',
36657
+ details: {
36658
+ vocab
36659
+ }
36660
+ },
36661
+ options
36662
+ });
36663
+ }
36664
+ }
36665
+ rval['@vocab'] = vocab;
36678
36666
  }
36679
36667
  defined.set('@vocab', true);
36680
36668
  }
@@ -36691,6 +36679,22 @@ api.process = async ({
36691
36679
  'jsonld.SyntaxError',
36692
36680
  {code: 'invalid default language', context: ctx});
36693
36681
  } else {
36682
+ if(!value.match(REGEX_BCP47)) {
36683
+ if(options.eventHandler) {
36684
+ _handleEvent({
36685
+ event: {
36686
+ type: ['JsonLdEvent'],
36687
+ code: 'invalid @language value',
36688
+ level: 'warning',
36689
+ message: '@language value must be valid BCP47.',
36690
+ details: {
36691
+ language: value
36692
+ }
36693
+ },
36694
+ options
36695
+ });
36696
+ }
36697
+ }
36694
36698
  rval['@language'] = value.toLowerCase();
36695
36699
  }
36696
36700
  defined.set('@language', true);
@@ -36856,7 +36860,10 @@ api.process = async ({
36856
36860
  }
36857
36861
 
36858
36862
  // cache processed result
36859
- resolvedContext.setProcessed(activeCtx, rval);
36863
+ resolvedContext.setProcessed(activeCtx, {
36864
+ context: rval,
36865
+ events
36866
+ });
36860
36867
  }
36861
36868
 
36862
36869
  return rval;
@@ -36871,9 +36878,6 @@ api.process = async ({
36871
36878
  * @param defined a map of defining/defined keys to detect cycles and prevent
36872
36879
  * double definitions.
36873
36880
  * @param {Object} [options] - creation options.
36874
- * @param {string} [options.protectedMode="error"] - "error" to throw error
36875
- * on `@protected` constraint violation, "warn" to allow violations and
36876
- * signal a warning.
36877
36881
  * @param overrideProtected `false` allows protected terms to be modified.
36878
36882
  */
36879
36883
  api.createTermDefinition = ({
@@ -36923,10 +36927,23 @@ api.createTermDefinition = ({
36923
36927
  'Invalid JSON-LD syntax; keywords cannot be overridden.',
36924
36928
  'jsonld.SyntaxError',
36925
36929
  {code: 'keyword redefinition', context: localCtx, term});
36926
- } else if(term.match(KEYWORD_PATTERN)) {
36927
- // FIXME: remove logging and use a handler
36928
- console.warn('WARNING: terms beginning with "@" are reserved' +
36929
- ' for future use and ignored', {term});
36930
+ } else if(term.match(REGEX_KEYWORD)) {
36931
+ if(options.eventHandler) {
36932
+ _handleEvent({
36933
+ event: {
36934
+ type: ['JsonLdEvent'],
36935
+ code: 'reserved term',
36936
+ level: 'warning',
36937
+ message:
36938
+ 'Terms beginning with "@" are ' +
36939
+ 'reserved for future use and dropped.',
36940
+ details: {
36941
+ term
36942
+ }
36943
+ },
36944
+ options
36945
+ });
36946
+ }
36930
36947
  return;
36931
36948
  } else if(term === '') {
36932
36949
  throw new JsonLdError(
@@ -37006,10 +37023,23 @@ api.createTermDefinition = ({
37006
37023
  'jsonld.SyntaxError', {code: 'invalid IRI mapping', context: localCtx});
37007
37024
  }
37008
37025
 
37009
- if(!api.isKeyword(reverse) && reverse.match(KEYWORD_PATTERN)) {
37010
- // FIXME: remove logging and use a handler
37011
- console.warn('WARNING: values beginning with "@" are reserved' +
37012
- ' for future use and ignored', {reverse});
37026
+ if(reverse.match(REGEX_KEYWORD)) {
37027
+ if(options.eventHandler) {
37028
+ _handleEvent({
37029
+ event: {
37030
+ type: ['JsonLdEvent'],
37031
+ code: 'reserved @reverse value',
37032
+ level: 'warning',
37033
+ message:
37034
+ '@reverse values beginning with "@" are ' +
37035
+ 'reserved for future use and dropped.',
37036
+ details: {
37037
+ reverse
37038
+ }
37039
+ },
37040
+ options
37041
+ });
37042
+ }
37013
37043
  if(previousMapping) {
37014
37044
  activeCtx.mappings.set(term, previousMapping);
37015
37045
  } else {
@@ -37042,10 +37072,23 @@ api.createTermDefinition = ({
37042
37072
  if(id === null) {
37043
37073
  // reserve a null term, which may be protected
37044
37074
  mapping['@id'] = null;
37045
- } else if(!api.isKeyword(id) && id.match(KEYWORD_PATTERN)) {
37046
- // FIXME: remove logging and use a handler
37047
- console.warn('WARNING: values beginning with "@" are reserved' +
37048
- ' for future use and ignored', {id});
37075
+ } else if(!api.isKeyword(id) && id.match(REGEX_KEYWORD)) {
37076
+ if(options.eventHandler) {
37077
+ _handleEvent({
37078
+ event: {
37079
+ type: ['JsonLdEvent'],
37080
+ code: 'reserved @id value',
37081
+ level: 'warning',
37082
+ message:
37083
+ '@id values beginning with "@" are ' +
37084
+ 'reserved for future use and dropped.',
37085
+ details: {
37086
+ id
37087
+ }
37088
+ },
37089
+ options
37090
+ });
37091
+ }
37049
37092
  if(previousMapping) {
37050
37093
  activeCtx.mappings.set(term, previousMapping);
37051
37094
  } else {
@@ -37360,23 +37403,10 @@ api.createTermDefinition = ({
37360
37403
  activeCtx.protected[term] = true;
37361
37404
  mapping.protected = true;
37362
37405
  if(!_deepCompare(previousMapping, mapping)) {
37363
- const protectedMode = (options && options.protectedMode) || 'error';
37364
- if(protectedMode === 'error') {
37365
- throw new JsonLdError(
37366
- `Invalid JSON-LD syntax; tried to redefine "${term}" which is a ` +
37367
- 'protected term.',
37368
- 'jsonld.SyntaxError',
37369
- {code: 'protected term redefinition', context: localCtx, term});
37370
- } else if(protectedMode === 'warn') {
37371
- // FIXME: remove logging and use a handler
37372
- console.warn('WARNING: protected term redefinition', {term});
37373
- return;
37374
- }
37375
37406
  throw new JsonLdError(
37376
- 'Invalid protectedMode.',
37407
+ 'Invalid JSON-LD syntax; tried to redefine a protected term.',
37377
37408
  'jsonld.SyntaxError',
37378
- {code: 'invalid protected mode', context: localCtx, term,
37379
- protectedMode});
37409
+ {code: 'protected term redefinition', context: localCtx, term});
37380
37410
  }
37381
37411
  }
37382
37412
  };
@@ -37425,7 +37455,7 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
37425
37455
  }
37426
37456
 
37427
37457
  // ignore non-keyword things that look like a keyword
37428
- if(value.match(KEYWORD_PATTERN)) {
37458
+ if(value.match(REGEX_KEYWORD)) {
37429
37459
  return null;
37430
37460
  }
37431
37461
 
@@ -37483,21 +37513,104 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
37483
37513
  }
37484
37514
  }
37485
37515
 
37486
- // prepend vocab
37487
- if(relativeTo.vocab && '@vocab' in activeCtx) {
37488
- return activeCtx['@vocab'] + value;
37489
- }
37516
+ // A flag that captures whether the iri being expanded is
37517
+ // the value for an @type
37518
+ //let typeExpansion = false;
37519
+
37520
+ //if(options !== undefined && options.typeExpansion !== undefined) {
37521
+ // typeExpansion = options.typeExpansion;
37522
+ //}
37490
37523
 
37491
- // prepend base
37492
- if(relativeTo.base && '@base' in activeCtx) {
37493
- if(activeCtx['@base']) {
37494
- // The null case preserves value as potentially relative
37495
- return prependBase(prependBase(options.base, activeCtx['@base']), value);
37524
+ if(relativeTo.vocab && '@vocab' in activeCtx) {
37525
+ // prepend vocab
37526
+ const prependedResult = activeCtx['@vocab'] + value;
37527
+ // FIXME: needed? may be better as debug event.
37528
+ /*
37529
+ if(options && options.eventHandler) {
37530
+ _handleEvent({
37531
+ event: {
37532
+ type: ['JsonLdEvent'],
37533
+ code: 'prepending @vocab during expansion',
37534
+ level: 'info',
37535
+ message: 'Prepending @vocab during expansion.',
37536
+ details: {
37537
+ type: '@vocab',
37538
+ vocab: activeCtx['@vocab'],
37539
+ value,
37540
+ result: prependedResult,
37541
+ typeExpansion
37542
+ }
37543
+ },
37544
+ options
37545
+ });
37496
37546
  }
37547
+ */
37548
+ // the null case preserves value as potentially relative
37549
+ value = prependedResult;
37497
37550
  } else if(relativeTo.base) {
37498
- return prependBase(options.base, value);
37551
+ // prepend base
37552
+ let prependedResult;
37553
+ let base;
37554
+ if('@base' in activeCtx) {
37555
+ if(activeCtx['@base']) {
37556
+ base = prependBase(options.base, activeCtx['@base']);
37557
+ prependedResult = prependBase(base, value);
37558
+ } else {
37559
+ base = activeCtx['@base'];
37560
+ prependedResult = value;
37561
+ }
37562
+ } else {
37563
+ base = options.base;
37564
+ prependedResult = prependBase(options.base, value);
37565
+ }
37566
+ // FIXME: needed? may be better as debug event.
37567
+ /*
37568
+ if(options && options.eventHandler) {
37569
+ _handleEvent({
37570
+ event: {
37571
+ type: ['JsonLdEvent'],
37572
+ code: 'prepending @base during expansion',
37573
+ level: 'info',
37574
+ message: 'Prepending @base during expansion.',
37575
+ details: {
37576
+ type: '@base',
37577
+ base,
37578
+ value,
37579
+ result: prependedResult,
37580
+ typeExpansion
37581
+ }
37582
+ },
37583
+ options
37584
+ });
37585
+ }
37586
+ */
37587
+ // the null case preserves value as potentially relative
37588
+ value = prependedResult;
37499
37589
  }
37500
37590
 
37591
+ // FIXME: duplicate? needed? maybe just enable in a verbose debug mode
37592
+ /*
37593
+ if(!_isAbsoluteIri(value) && options && options.eventHandler) {
37594
+ // emit event indicating a relative IRI was found, which can result in it
37595
+ // being dropped when converting to other RDF representations
37596
+ _handleEvent({
37597
+ event: {
37598
+ type: ['JsonLdEvent'],
37599
+ code: 'relative IRI after expansion',
37600
+ // FIXME: what level?
37601
+ level: 'warning',
37602
+ message: 'Relative IRI after expansion.',
37603
+ details: {
37604
+ relativeIri: value,
37605
+ typeExpansion
37606
+ }
37607
+ },
37608
+ options
37609
+ });
37610
+ // NOTE: relative reference events emitted at calling sites as needed
37611
+ }
37612
+ */
37613
+
37501
37614
  return value;
37502
37615
  }
37503
37616
 
@@ -38013,7 +38126,7 @@ module.exports = ({
38013
38126
  }
38014
38127
 
38015
38128
  // "alternate" link header is a redirect
38016
- alternate = linkHeaders['alternate'];
38129
+ alternate = linkHeaders.alternate;
38017
38130
  if(alternate &&
38018
38131
  alternate.type == 'application/ld+json' &&
38019
38132
  !(contentType || '').match(/^application\/(\w*\+)?json$/)) {
@@ -38040,6 +38153,195 @@ function _get(xhr, url, headers) {
38040
38153
  }
38041
38154
 
38042
38155
 
38156
+ /***/ }),
38157
+
38158
+ /***/ "./node_modules/jsonld/lib/events.js":
38159
+ /*!*******************************************!*\
38160
+ !*** ./node_modules/jsonld/lib/events.js ***!
38161
+ \*******************************************/
38162
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
38163
+
38164
+ "use strict";
38165
+ /*
38166
+ * Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
38167
+ */
38168
+
38169
+
38170
+ const JsonLdError = __webpack_require__(/*! ./JsonLdError */ "./node_modules/jsonld/lib/JsonLdError.js");
38171
+
38172
+ const {
38173
+ isArray: _isArray
38174
+ } = __webpack_require__(/*! ./types */ "./node_modules/jsonld/lib/types.js");
38175
+
38176
+ const {
38177
+ asArray: _asArray
38178
+ } = __webpack_require__(/*! ./util */ "./node_modules/jsonld/lib/util.js");
38179
+
38180
+ const api = {};
38181
+ module.exports = api;
38182
+
38183
+ // default handler, store as null or an array
38184
+ // exposed to allow fast external pre-handleEvent() checks
38185
+ api.defaultEventHandler = null;
38186
+
38187
+ /**
38188
+ * Setup event handler.
38189
+ *
38190
+ * Return an array event handler constructed from an optional safe mode
38191
+ * handler, an optional options event handler, and an optional default handler.
38192
+ *
38193
+ * @param {object} options - processing options
38194
+ * {function|object|array} [eventHandler] - an event handler.
38195
+ *
38196
+ * @return an array event handler.
38197
+ */
38198
+ api.setupEventHandler = ({options = {}}) => {
38199
+ // build in priority order
38200
+ const eventHandler = [].concat(
38201
+ options.safe ? api.safeEventHandler : [],
38202
+ options.eventHandler ? _asArray(options.eventHandler) : [],
38203
+ api.defaultEventHandler ? api.defaultEventHandler : []
38204
+ );
38205
+ // null if no handlers
38206
+ return eventHandler.length === 0 ? null : eventHandler;
38207
+ };
38208
+
38209
+ /**
38210
+ * Handle an event.
38211
+ *
38212
+ * Top level APIs have a common 'eventHandler' option. This option can be a
38213
+ * function, array of functions, object mapping event.code to functions (with a
38214
+ * default to call next()), or any combination of such handlers. Handlers will
38215
+ * be called with an object with an 'event' entry and a 'next' function. Custom
38216
+ * handlers should process the event as appropriate. The 'next()' function
38217
+ * should be called to let the next handler process the event.
38218
+ *
38219
+ * NOTE: Only call this function if options.eventHandler is set and is an
38220
+ * array of hanlers. This is an optimization. Callers are expected to check
38221
+ * for an event handler before constructing events and calling this function.
38222
+ *
38223
+ * @param {object} event - event structure:
38224
+ * {string} code - event code
38225
+ * {string} level - severity level, one of: ['warning']
38226
+ * {string} message - human readable message
38227
+ * {object} details - event specific details
38228
+ * @param {object} options - processing options
38229
+ * {array} eventHandler - an event handler array.
38230
+ */
38231
+ api.handleEvent = ({
38232
+ event,
38233
+ options
38234
+ }) => {
38235
+ _handle({event, handlers: options.eventHandler});
38236
+ };
38237
+
38238
+ function _handle({event, handlers}) {
38239
+ let doNext = true;
38240
+ for(let i = 0; doNext && i < handlers.length; ++i) {
38241
+ doNext = false;
38242
+ const handler = handlers[i];
38243
+ if(_isArray(handler)) {
38244
+ doNext = _handle({event, handlers: handler});
38245
+ } else if(typeof handler === 'function') {
38246
+ handler({event, next: () => {
38247
+ doNext = true;
38248
+ }});
38249
+ } else if(typeof handler === 'object') {
38250
+ if(event.code in handler) {
38251
+ handler[event.code]({event, next: () => {
38252
+ doNext = true;
38253
+ }});
38254
+ } else {
38255
+ doNext = true;
38256
+ }
38257
+ } else {
38258
+ throw new JsonLdError(
38259
+ 'Invalid event handler.',
38260
+ 'jsonld.InvalidEventHandler',
38261
+ {event});
38262
+ }
38263
+ }
38264
+ return doNext;
38265
+ }
38266
+
38267
+ const _notSafeEventCodes = new Set([
38268
+ 'empty object',
38269
+ 'free-floating scalar',
38270
+ 'invalid @language value',
38271
+ 'invalid property',
38272
+ // NOTE: spec edge case
38273
+ 'null @id value',
38274
+ 'null @value value',
38275
+ 'object with only @id',
38276
+ 'object with only @language',
38277
+ 'object with only @list',
38278
+ 'object with only @value',
38279
+ 'relative @id reference',
38280
+ 'relative @type reference',
38281
+ 'relative @vocab reference',
38282
+ 'reserved @id value',
38283
+ 'reserved @reverse value',
38284
+ 'reserved term',
38285
+ // toRDF
38286
+ 'blank node predicate',
38287
+ 'relative graph reference',
38288
+ 'relative object reference',
38289
+ 'relative predicate reference',
38290
+ 'relative subject reference'
38291
+ ]);
38292
+
38293
+ // safe handler that rejects unsafe warning conditions
38294
+ api.safeEventHandler = function safeEventHandler({event, next}) {
38295
+ // fail on all unsafe warnings
38296
+ if(event.level === 'warning' && _notSafeEventCodes.has(event.code)) {
38297
+ throw new JsonLdError(
38298
+ 'Safe mode validation error.',
38299
+ 'jsonld.ValidationError',
38300
+ {event}
38301
+ );
38302
+ }
38303
+ next();
38304
+ };
38305
+
38306
+ // logs all events and continues
38307
+ api.logEventHandler = function logEventHandler({event, next}) {
38308
+ console.log(`EVENT: ${event.message}`, {event});
38309
+ next();
38310
+ };
38311
+
38312
+ // log 'warning' level events
38313
+ api.logWarningEventHandler = function logWarningEventHandler({event, next}) {
38314
+ if(event.level === 'warning') {
38315
+ console.warn(`WARNING: ${event.message}`, {event});
38316
+ }
38317
+ next();
38318
+ };
38319
+
38320
+ // fallback to throw errors for any unhandled events
38321
+ api.unhandledEventHandler = function unhandledEventHandler({event}) {
38322
+ throw new JsonLdError(
38323
+ 'No handler for event.',
38324
+ 'jsonld.UnhandledEvent',
38325
+ {event}
38326
+ );
38327
+ };
38328
+
38329
+ /**
38330
+ * Set default event handler.
38331
+ *
38332
+ * By default, all event are unhandled. It is recommended to pass in an
38333
+ * eventHandler into each call. However, this call allows using a default
38334
+ * eventHandler when one is not otherwise provided.
38335
+ *
38336
+ * @param {object} options - default handler options:
38337
+ * {function|object|array} eventHandler - a default event handler.
38338
+ * falsey to unset.
38339
+ */
38340
+ api.setDefaultEventHandler = function({eventHandler} = {}) {
38341
+ api.defaultEventHandler = eventHandler ? _asArray(eventHandler) : null;
38342
+ };
38343
+
38344
+
38043
38345
  /***/ }),
38044
38346
 
38045
38347
  /***/ "./node_modules/jsonld/lib/expand.js":
@@ -38084,15 +38386,20 @@ const {
38084
38386
  } = __webpack_require__(/*! ./url */ "./node_modules/jsonld/lib/url.js");
38085
38387
 
38086
38388
  const {
38389
+ REGEX_BCP47,
38390
+ REGEX_KEYWORD,
38087
38391
  addValue: _addValue,
38088
38392
  asArray: _asArray,
38089
38393
  getValues: _getValues,
38090
38394
  validateTypeValue: _validateTypeValue
38091
38395
  } = __webpack_require__(/*! ./util */ "./node_modules/jsonld/lib/util.js");
38092
38396
 
38397
+ const {
38398
+ handleEvent: _handleEvent
38399
+ } = __webpack_require__(/*! ./events */ "./node_modules/jsonld/lib/events.js");
38400
+
38093
38401
  const api = {};
38094
38402
  module.exports = api;
38095
- const REGEX_BCP47 = /^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/;
38096
38403
 
38097
38404
  /**
38098
38405
  * Recursively expands an element using the given context. Any context in
@@ -38109,10 +38416,6 @@ const REGEX_BCP47 = /^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/;
38109
38416
  * @param typeScopedContext an optional type-scoped active context for
38110
38417
  * expanding values of nodes that were expressed according to
38111
38418
  * a type-scoped context.
38112
- * @param expansionMap(info) a function that can be used to custom map
38113
- * unmappable values (or to throw an error when they are detected);
38114
- * if this function returns `undefined` then the default behavior
38115
- * will be used.
38116
38419
  *
38117
38420
  * @return a Promise that resolves to the expanded value.
38118
38421
  */
@@ -38123,8 +38426,7 @@ api.expand = async ({
38123
38426
  options = {},
38124
38427
  insideList = false,
38125
38428
  insideIndex = false,
38126
- typeScopedContext = null,
38127
- expansionMap = () => undefined
38429
+ typeScopedContext = null
38128
38430
  }) => {
38129
38431
  // nothing to expand
38130
38432
  if(element === null || element === undefined) {
@@ -38137,21 +38439,28 @@ api.expand = async ({
38137
38439
  }
38138
38440
 
38139
38441
  if(!_isArray(element) && !_isObject(element)) {
38140
- // drop free-floating scalars that are not in lists unless custom mapped
38442
+ // drop free-floating scalars that are not in lists
38141
38443
  if(!insideList && (activeProperty === null ||
38142
38444
  _expandIri(activeCtx, activeProperty, {vocab: true},
38143
38445
  options) === '@graph')) {
38144
- const mapped = await expansionMap({
38145
- unmappedValue: element,
38146
- activeCtx,
38147
- activeProperty,
38148
- options,
38149
- insideList
38150
- });
38151
- if(mapped === undefined) {
38152
- return null;
38446
+ // FIXME
38447
+ if(options.eventHandler) {
38448
+ _handleEvent({
38449
+ event: {
38450
+ type: ['JsonLdEvent'],
38451
+ code: 'free-floating scalar',
38452
+ level: 'warning',
38453
+ message: 'Dropping free-floating scalar not in a list.',
38454
+ details: {
38455
+ value: element
38456
+ //activeProperty
38457
+ //insideList
38458
+ }
38459
+ },
38460
+ options
38461
+ });
38153
38462
  }
38154
- return mapped;
38463
+ return null;
38155
38464
  }
38156
38465
 
38157
38466
  // expand element according to value expansion rules
@@ -38171,7 +38480,6 @@ api.expand = async ({
38171
38480
  activeProperty,
38172
38481
  element: element[i],
38173
38482
  options,
38174
- expansionMap,
38175
38483
  insideIndex,
38176
38484
  typeScopedContext
38177
38485
  });
@@ -38180,19 +38488,16 @@ api.expand = async ({
38180
38488
  }
38181
38489
 
38182
38490
  if(e === null) {
38183
- e = await expansionMap({
38184
- unmappedValue: element[i],
38185
- activeCtx,
38186
- activeProperty,
38187
- parent: element,
38188
- index: i,
38189
- options,
38190
- expandedParent: rval,
38191
- insideList
38192
- });
38193
- if(e === undefined) {
38194
- continue;
38195
- }
38491
+ // FIXME: add debug event?
38492
+ //unmappedValue: element[i],
38493
+ //activeProperty,
38494
+ //parent: element,
38495
+ //index: i,
38496
+ //expandedParent: rval,
38497
+ //insideList
38498
+
38499
+ // NOTE: no-value events emitted at calling sites as needed
38500
+ continue;
38196
38501
  }
38197
38502
 
38198
38503
  if(_isArray(e)) {
@@ -38305,8 +38610,8 @@ api.expand = async ({
38305
38610
  options,
38306
38611
  insideList,
38307
38612
  typeKey,
38308
- typeScopedContext,
38309
- expansionMap});
38613
+ typeScopedContext
38614
+ });
38310
38615
 
38311
38616
  // get property count on expanded output
38312
38617
  keys = Object.keys(rval);
@@ -38343,24 +38648,27 @@ api.expand = async ({
38343
38648
  const values = rval['@value'] === null ? [] : _asArray(rval['@value']);
38344
38649
  const types = _getValues(rval, '@type');
38345
38650
 
38346
- // drop null @values unless custom mapped
38651
+ // drop null @values
38347
38652
  if(_processingMode(activeCtx, 1.1) && types.includes('@json') &&
38348
38653
  types.length === 1) {
38349
38654
  // Any value of @value is okay if @type: @json
38350
38655
  } else if(values.length === 0) {
38351
- const mapped = await expansionMap({
38352
- unmappedValue: rval,
38353
- activeCtx,
38354
- activeProperty,
38355
- element,
38356
- options,
38357
- insideList
38358
- });
38359
- if(mapped !== undefined) {
38360
- rval = mapped;
38361
- } else {
38362
- rval = null;
38656
+ // FIXME
38657
+ if(options.eventHandler) {
38658
+ _handleEvent({
38659
+ event: {
38660
+ type: ['JsonLdEvent'],
38661
+ code: 'null @value value',
38662
+ level: 'warning',
38663
+ message: 'Dropping null @value value.',
38664
+ details: {
38665
+ value: rval
38666
+ }
38667
+ },
38668
+ options
38669
+ });
38363
38670
  }
38671
+ rval = null;
38364
38672
  } else if(!values.every(v => (_isString(v) || _isEmptyObject(v))) &&
38365
38673
  '@language' in rval) {
38366
38674
  // if @language is present, @value must be a string
@@ -38395,43 +38703,64 @@ api.expand = async ({
38395
38703
  count = keys.length;
38396
38704
  }
38397
38705
  } else if(count === 1 && '@language' in rval) {
38398
- // drop objects with only @language unless custom mapped
38399
- const mapped = await expansionMap(rval, {
38400
- unmappedValue: rval,
38401
- activeCtx,
38402
- activeProperty,
38403
- element,
38404
- options,
38405
- insideList
38406
- });
38407
- if(mapped !== undefined) {
38408
- rval = mapped;
38409
- } else {
38410
- rval = null;
38706
+ // drop objects with only @language
38707
+ // FIXME
38708
+ if(options.eventHandler) {
38709
+ _handleEvent({
38710
+ event: {
38711
+ type: ['JsonLdEvent'],
38712
+ code: 'object with only @language',
38713
+ level: 'warning',
38714
+ message: 'Dropping object with only @language.',
38715
+ details: {
38716
+ value: rval
38717
+ }
38718
+ },
38719
+ options
38720
+ });
38411
38721
  }
38722
+ rval = null;
38412
38723
  }
38413
38724
 
38414
- // drop certain top-level objects that do not occur in lists, unless custom
38415
- // mapped
38725
+ // drop certain top-level objects that do not occur in lists
38416
38726
  if(_isObject(rval) &&
38417
38727
  !options.keepFreeFloatingNodes && !insideList &&
38418
38728
  (activeProperty === null || expandedActiveProperty === '@graph')) {
38419
38729
  // drop empty object, top-level @value/@list, or object with only @id
38420
38730
  if(count === 0 || '@value' in rval || '@list' in rval ||
38421
38731
  (count === 1 && '@id' in rval)) {
38422
- const mapped = await expansionMap({
38423
- unmappedValue: rval,
38424
- activeCtx,
38425
- activeProperty,
38426
- element,
38427
- options,
38428
- insideList
38429
- });
38430
- if(mapped !== undefined) {
38431
- rval = mapped;
38432
- } else {
38433
- rval = null;
38732
+ // FIXME
38733
+ if(options.eventHandler) {
38734
+ // FIXME: one event or diff event for empty, @v/@l, {@id}?
38735
+ let code;
38736
+ let message;
38737
+ if(count === 0) {
38738
+ code = 'empty object';
38739
+ message = 'Dropping empty object.';
38740
+ } else if('@value' in rval) {
38741
+ code = 'object with only @value';
38742
+ message = 'Dropping object with only @value.';
38743
+ } else if('@list' in rval) {
38744
+ code = 'object with only @list';
38745
+ message = 'Dropping object with only @list.';
38746
+ } else if(count === 1 && '@id' in rval) {
38747
+ code = 'object with only @id';
38748
+ message = 'Dropping object with only @id.';
38749
+ }
38750
+ _handleEvent({
38751
+ event: {
38752
+ type: ['JsonLdEvent'],
38753
+ code,
38754
+ level: 'warning',
38755
+ message,
38756
+ details: {
38757
+ value: rval
38758
+ }
38759
+ },
38760
+ options
38761
+ });
38434
38762
  }
38763
+ rval = null;
38435
38764
  }
38436
38765
  }
38437
38766
 
@@ -38450,10 +38779,6 @@ api.expand = async ({
38450
38779
  * @param insideList true if the element is a list, false if not.
38451
38780
  * @param typeKey first key found expanding to @type.
38452
38781
  * @param typeScopedContext the context before reverting.
38453
- * @param expansionMap(info) a function that can be used to custom map
38454
- * unmappable values (or to throw an error when they are detected);
38455
- * if this function returns `undefined` then the default behavior
38456
- * will be used.
38457
38782
  */
38458
38783
  async function _expandObject({
38459
38784
  activeCtx,
@@ -38464,8 +38789,7 @@ async function _expandObject({
38464
38789
  options = {},
38465
38790
  insideList,
38466
38791
  typeKey,
38467
- typeScopedContext,
38468
- expansionMap
38792
+ typeScopedContext
38469
38793
  }) {
38470
38794
  const keys = Object.keys(element).sort();
38471
38795
  const nests = [];
@@ -38475,7 +38799,10 @@ async function _expandObject({
38475
38799
  const isJsonType = element[typeKey] &&
38476
38800
  _expandIri(activeCtx,
38477
38801
  (_isArray(element[typeKey]) ? element[typeKey][0] : element[typeKey]),
38478
- {vocab: true}, options) === '@json';
38802
+ {vocab: true}, {
38803
+ ...options,
38804
+ typeExpansion: true
38805
+ }) === '@json';
38479
38806
 
38480
38807
  for(const key of keys) {
38481
38808
  let value = element[key];
@@ -38487,25 +38814,28 @@ async function _expandObject({
38487
38814
  }
38488
38815
 
38489
38816
  // expand property
38490
- let expandedProperty = _expandIri(activeCtx, key, {vocab: true}, options);
38817
+ const expandedProperty = _expandIri(activeCtx, key, {vocab: true}, options);
38491
38818
 
38492
- // drop non-absolute IRI keys that aren't keywords unless custom mapped
38819
+ // drop non-absolute IRI keys that aren't keywords
38493
38820
  if(expandedProperty === null ||
38494
38821
  !(_isAbsoluteIri(expandedProperty) || _isKeyword(expandedProperty))) {
38495
- // TODO: use `await` to support async
38496
- expandedProperty = expansionMap({
38497
- unmappedProperty: key,
38498
- activeCtx,
38499
- activeProperty,
38500
- parent: element,
38501
- options,
38502
- insideList,
38503
- value,
38504
- expandedParent
38505
- });
38506
- if(expandedProperty === undefined) {
38507
- continue;
38822
+ if(options.eventHandler) {
38823
+ _handleEvent({
38824
+ event: {
38825
+ type: ['JsonLdEvent'],
38826
+ code: 'invalid property',
38827
+ level: 'warning',
38828
+ message: 'Dropping property that did not expand into an ' +
38829
+ 'absolute IRI or keyword.',
38830
+ details: {
38831
+ property: key,
38832
+ expandedProperty
38833
+ }
38834
+ },
38835
+ options
38836
+ });
38508
38837
  }
38838
+ continue;
38509
38839
  }
38510
38840
 
38511
38841
  if(_isKeyword(expandedProperty)) {
@@ -38558,8 +38888,61 @@ async function _expandObject({
38558
38888
 
38559
38889
  _addValue(
38560
38890
  expandedParent, '@id',
38561
- _asArray(value).map(v =>
38562
- _isString(v) ? _expandIri(activeCtx, v, {base: true}, options) : v),
38891
+ _asArray(value).map(v => {
38892
+ if(_isString(v)) {
38893
+ const ve = _expandIri(activeCtx, v, {base: true}, options);
38894
+ if(options.eventHandler) {
38895
+ if(ve === null) {
38896
+ // NOTE: spec edge case
38897
+ // See https://github.com/w3c/json-ld-api/issues/480
38898
+ if(v === null) {
38899
+ _handleEvent({
38900
+ event: {
38901
+ type: ['JsonLdEvent'],
38902
+ code: 'null @id value',
38903
+ level: 'warning',
38904
+ message: 'Null @id found.',
38905
+ details: {
38906
+ id: v
38907
+ }
38908
+ },
38909
+ options
38910
+ });
38911
+ } else {
38912
+ // matched KEYWORD regex
38913
+ _handleEvent({
38914
+ event: {
38915
+ type: ['JsonLdEvent'],
38916
+ code: 'reserved @id value',
38917
+ level: 'warning',
38918
+ message: 'Reserved @id found.',
38919
+ details: {
38920
+ id: v
38921
+ }
38922
+ },
38923
+ options
38924
+ });
38925
+ }
38926
+ } else if(!_isAbsoluteIri(ve)) {
38927
+ _handleEvent({
38928
+ event: {
38929
+ type: ['JsonLdEvent'],
38930
+ code: 'relative @id reference',
38931
+ level: 'warning',
38932
+ message: 'Relative @id reference found.',
38933
+ details: {
38934
+ id: v,
38935
+ expandedId: ve
38936
+ }
38937
+ },
38938
+ options
38939
+ });
38940
+ }
38941
+ }
38942
+ return ve;
38943
+ }
38944
+ return v;
38945
+ }),
38563
38946
  {propertyIsArray: options.isFrame});
38564
38947
  continue;
38565
38948
  }
@@ -38571,17 +38954,39 @@ async function _expandObject({
38571
38954
  value = Object.fromEntries(Object.entries(value).map(([k, v]) => [
38572
38955
  _expandIri(typeScopedContext, k, {vocab: true}),
38573
38956
  _asArray(v).map(vv =>
38574
- _expandIri(typeScopedContext, vv, {base: true, vocab: true})
38957
+ _expandIri(typeScopedContext, vv, {base: true, vocab: true},
38958
+ {...options, typeExpansion: true})
38575
38959
  )
38576
38960
  ]));
38577
38961
  }
38578
38962
  _validateTypeValue(value, options.isFrame);
38579
38963
  _addValue(
38580
38964
  expandedParent, '@type',
38581
- _asArray(value).map(v =>
38582
- _isString(v) ?
38583
- _expandIri(typeScopedContext, v,
38584
- {base: true, vocab: true}, options) : v),
38965
+ _asArray(value).map(v => {
38966
+ if(_isString(v)) {
38967
+ const ve = _expandIri(typeScopedContext, v,
38968
+ {base: true, vocab: true},
38969
+ {...options, typeExpansion: true});
38970
+ if(ve !== '@json' && !_isAbsoluteIri(ve)) {
38971
+ if(options.eventHandler) {
38972
+ _handleEvent({
38973
+ event: {
38974
+ type: ['JsonLdEvent'],
38975
+ code: 'relative @type reference',
38976
+ level: 'warning',
38977
+ message: 'Relative @type reference found.',
38978
+ details: {
38979
+ type: v
38980
+ }
38981
+ },
38982
+ options
38983
+ });
38984
+ }
38985
+ }
38986
+ return ve;
38987
+ }
38988
+ return v;
38989
+ }),
38585
38990
  {propertyIsArray: options.isFrame});
38586
38991
  continue;
38587
38992
  }
@@ -38594,8 +38999,7 @@ async function _expandObject({
38594
38999
  activeCtx,
38595
39000
  activeProperty,
38596
39001
  element: value,
38597
- options,
38598
- expansionMap
39002
+ options
38599
39003
  }));
38600
39004
 
38601
39005
  // Expanded values must be node objects
@@ -38651,9 +39055,22 @@ async function _expandObject({
38651
39055
  value = _asArray(value).map(v => _isString(v) ? v.toLowerCase() : v);
38652
39056
 
38653
39057
  // ensure language tag matches BCP47
38654
- for(const lang of value) {
38655
- if(_isString(lang) && !lang.match(REGEX_BCP47)) {
38656
- console.warn(`@language must be valid BCP47: ${lang}`);
39058
+ for(const language of value) {
39059
+ if(_isString(language) && !language.match(REGEX_BCP47)) {
39060
+ if(options.eventHandler) {
39061
+ _handleEvent({
39062
+ event: {
39063
+ type: ['JsonLdEvent'],
39064
+ code: 'invalid @language value',
39065
+ level: 'warning',
39066
+ message: '@language value must be valid BCP47.',
39067
+ details: {
39068
+ language
39069
+ }
39070
+ },
39071
+ options
39072
+ });
39073
+ }
38657
39074
  }
38658
39075
  }
38659
39076
 
@@ -38714,8 +39131,7 @@ async function _expandObject({
38714
39131
  activeProperty:
38715
39132
  '@reverse',
38716
39133
  element: value,
38717
- options,
38718
- expansionMap
39134
+ options
38719
39135
  });
38720
39136
  // properties double-reversed
38721
39137
  if('@reverse' in expandedValue) {
@@ -38790,7 +39206,6 @@ async function _expandObject({
38790
39206
  options,
38791
39207
  activeProperty: key,
38792
39208
  value,
38793
- expansionMap,
38794
39209
  asGraph,
38795
39210
  indexKey,
38796
39211
  propertyIndex
@@ -38803,7 +39218,6 @@ async function _expandObject({
38803
39218
  options,
38804
39219
  activeProperty: key,
38805
39220
  value,
38806
- expansionMap,
38807
39221
  asGraph,
38808
39222
  indexKey: '@id'
38809
39223
  });
@@ -38815,7 +39229,6 @@ async function _expandObject({
38815
39229
  options,
38816
39230
  activeProperty: key,
38817
39231
  value,
38818
- expansionMap,
38819
39232
  asGraph: false,
38820
39233
  indexKey: '@type'
38821
39234
  });
@@ -38832,8 +39245,7 @@ async function _expandObject({
38832
39245
  activeProperty: nextActiveProperty,
38833
39246
  element: value,
38834
39247
  options,
38835
- insideList: isList,
38836
- expansionMap
39248
+ insideList: isList
38837
39249
  });
38838
39250
  } else if(
38839
39251
  _getContextValue(activeCtx, key, '@type') === '@json') {
@@ -38848,29 +39260,18 @@ async function _expandObject({
38848
39260
  activeProperty: key,
38849
39261
  element: value,
38850
39262
  options,
38851
- insideList: false,
38852
- expansionMap
39263
+ insideList: false
38853
39264
  });
38854
39265
  }
38855
39266
  }
38856
39267
 
38857
39268
  // drop null values if property is not @value
38858
39269
  if(expandedValue === null && expandedProperty !== '@value') {
38859
- // TODO: use `await` to support async
38860
- expandedValue = expansionMap({
38861
- unmappedValue: value,
38862
- expandedProperty,
38863
- activeCtx: termCtx,
38864
- activeProperty,
38865
- parent: element,
38866
- options,
38867
- insideList,
38868
- key,
38869
- expandedParent
38870
- });
38871
- if(expandedValue === undefined) {
38872
- continue;
38873
- }
39270
+ // FIXME: event?
39271
+ //unmappedValue: value,
39272
+ //expandedProperty,
39273
+ //key,
39274
+ continue;
38874
39275
  }
38875
39276
 
38876
39277
  // convert expanded value to @list if container specifies it
@@ -38952,8 +39353,8 @@ async function _expandObject({
38952
39353
  options,
38953
39354
  insideList,
38954
39355
  typeScopedContext,
38955
- typeKey,
38956
- expansionMap});
39356
+ typeKey
39357
+ });
38957
39358
  }
38958
39359
  }
38959
39360
  }
@@ -38981,7 +39382,8 @@ function _expandValue({activeCtx, activeProperty, value, options}) {
38981
39382
  if(expandedProperty === '@id') {
38982
39383
  return _expandIri(activeCtx, value, {base: true}, options);
38983
39384
  } else if(expandedProperty === '@type') {
38984
- return _expandIri(activeCtx, value, {vocab: true, base: true}, options);
39385
+ return _expandIri(activeCtx, value, {vocab: true, base: true},
39386
+ {...options, typeExpansion: true});
38985
39387
  }
38986
39388
 
38987
39389
  // get type definition from context
@@ -38989,7 +39391,25 @@ function _expandValue({activeCtx, activeProperty, value, options}) {
38989
39391
 
38990
39392
  // do @id expansion (automatic for @graph)
38991
39393
  if((type === '@id' || expandedProperty === '@graph') && _isString(value)) {
38992
- return {'@id': _expandIri(activeCtx, value, {base: true}, options)};
39394
+ const expandedValue = _expandIri(activeCtx, value, {base: true}, options);
39395
+ // NOTE: handle spec edge case and avoid invalid {"@id": null}
39396
+ if(expandedValue === null && value.match(REGEX_KEYWORD)) {
39397
+ if(options.eventHandler) {
39398
+ _handleEvent({
39399
+ event: {
39400
+ type: ['JsonLdEvent'],
39401
+ code: 'reserved @id value',
39402
+ level: 'warning',
39403
+ message: 'Reserved @id found.',
39404
+ details: {
39405
+ id: activeProperty
39406
+ }
39407
+ },
39408
+ options
39409
+ });
39410
+ }
39411
+ }
39412
+ return {'@id': expandedValue};
38993
39413
  }
38994
39414
  // do @id expansion w/vocab
38995
39415
  if(type === '@vocab' && _isString(value)) {
@@ -39060,6 +39480,22 @@ function _expandLanguageMap(activeCtx, languageMap, direction, options) {
39060
39480
  }
39061
39481
  const val = {'@value': item};
39062
39482
  if(expandedKey !== '@none') {
39483
+ if(!key.match(REGEX_BCP47)) {
39484
+ if(options.eventHandler) {
39485
+ _handleEvent({
39486
+ event: {
39487
+ type: ['JsonLdEvent'],
39488
+ code: 'invalid @language value',
39489
+ level: 'warning',
39490
+ message: '@language value must be valid BCP47.',
39491
+ details: {
39492
+ language: key
39493
+ }
39494
+ },
39495
+ options
39496
+ });
39497
+ }
39498
+ }
39063
39499
  val['@language'] = key.toLowerCase();
39064
39500
  }
39065
39501
  if(direction) {
@@ -39071,9 +39507,9 @@ function _expandLanguageMap(activeCtx, languageMap, direction, options) {
39071
39507
  return rval;
39072
39508
  }
39073
39509
 
39074
- async function _expandIndexMap(
39075
- {activeCtx, options, activeProperty, value, expansionMap, asGraph,
39076
- indexKey, propertyIndex}) {
39510
+ async function _expandIndexMap({
39511
+ activeCtx, options, activeProperty, value, asGraph, indexKey, propertyIndex
39512
+ }) {
39077
39513
  const rval = [];
39078
39514
  const keys = Object.keys(value).sort();
39079
39515
  const isTypeIndex = indexKey === '@type';
@@ -39102,8 +39538,7 @@ async function _expandIndexMap(
39102
39538
  element: val,
39103
39539
  options,
39104
39540
  insideList: false,
39105
- insideIndex: true,
39106
- expansionMap
39541
+ insideIndex: true
39107
39542
  });
39108
39543
 
39109
39544
  // expand for @type, but also for @none
@@ -40068,7 +40503,15 @@ function _valueMatch(pattern, value) {
40068
40503
  const JsonLdError = __webpack_require__(/*! ./JsonLdError */ "./node_modules/jsonld/lib/JsonLdError.js");
40069
40504
  const graphTypes = __webpack_require__(/*! ./graphTypes */ "./node_modules/jsonld/lib/graphTypes.js");
40070
40505
  const types = __webpack_require__(/*! ./types */ "./node_modules/jsonld/lib/types.js");
40071
- const util = __webpack_require__(/*! ./util */ "./node_modules/jsonld/lib/util.js");
40506
+
40507
+ const {
40508
+ REGEX_BCP47,
40509
+ addValue: _addValue
40510
+ } = __webpack_require__(/*! ./util */ "./node_modules/jsonld/lib/util.js");
40511
+
40512
+ const {
40513
+ handleEvent: _handleEvent
40514
+ } = __webpack_require__(/*! ./events */ "./node_modules/jsonld/lib/events.js");
40072
40515
 
40073
40516
  // constants
40074
40517
  const {
@@ -40091,8 +40534,6 @@ const {
40091
40534
  XSD_STRING,
40092
40535
  } = __webpack_require__(/*! ./constants */ "./node_modules/jsonld/lib/constants.js");
40093
40536
 
40094
- const REGEX_BCP47 = /^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/;
40095
-
40096
40537
  const api = {};
40097
40538
  module.exports = api;
40098
40539
 
@@ -40106,15 +40547,16 @@ module.exports = api;
40106
40547
  */
40107
40548
  api.fromRDF = async (
40108
40549
  dataset,
40109
- {
40110
- useRdfType = false,
40111
- useNativeTypes = false,
40112
- rdfDirection = null
40113
- }
40550
+ options
40114
40551
  ) => {
40115
40552
  const defaultGraph = {};
40116
40553
  const graphMap = {'@default': defaultGraph};
40117
40554
  const referencedOnce = {};
40555
+ const {
40556
+ useRdfType = false,
40557
+ useNativeTypes = false,
40558
+ rdfDirection = null
40559
+ } = options;
40118
40560
 
40119
40561
  for(const quad of dataset) {
40120
40562
  // TODO: change 'name' to 'graph'
@@ -40145,12 +40587,12 @@ api.fromRDF = async (
40145
40587
  }
40146
40588
 
40147
40589
  if(p === RDF_TYPE && !useRdfType && objectIsNode) {
40148
- util.addValue(node, '@type', o.value, {propertyIsArray: true});
40590
+ _addValue(node, '@type', o.value, {propertyIsArray: true});
40149
40591
  continue;
40150
40592
  }
40151
40593
 
40152
- const value = _RDFToObject(o, useNativeTypes, rdfDirection);
40153
- util.addValue(node, p, value, {propertyIsArray: true});
40594
+ const value = _RDFToObject(o, useNativeTypes, rdfDirection, options);
40595
+ _addValue(node, p, value, {propertyIsArray: true});
40154
40596
 
40155
40597
  // object may be an RDF list/partial list node but we can't know easily
40156
40598
  // until all triples are read
@@ -40209,12 +40651,12 @@ api.fromRDF = async (
40209
40651
  }
40210
40652
 
40211
40653
  if(p === RDF_TYPE && !useRdfType && objectIsId) {
40212
- util.addValue(node, '@type', o.value, {propertyIsArray: true});
40654
+ _addValue(node, '@type', o.value, {propertyIsArray: true});
40213
40655
  continue;
40214
40656
  }
40215
40657
 
40216
40658
  const value = _RDFToObject(o, useNativeTypes);
40217
- util.addValue(node, p, value, {propertyIsArray: true});
40659
+ _addValue(node, p, value, {propertyIsArray: true});
40218
40660
 
40219
40661
  // object may be an RDF list/partial list node but we can't know easily
40220
40662
  // until all triples are read
@@ -40337,10 +40779,12 @@ api.fromRDF = async (
40337
40779
  *
40338
40780
  * @param o the RDF triple object to convert.
40339
40781
  * @param useNativeTypes true to output native types, false not to.
40782
+ * @param rdfDirection text direction mode [null, i18n-datatype]
40783
+ * @param options top level API options
40340
40784
  *
40341
40785
  * @return the JSON-LD object.
40342
40786
  */
40343
- function _RDFToObject(o, useNativeTypes, rdfDirection) {
40787
+ function _RDFToObject(o, useNativeTypes, rdfDirection, options) {
40344
40788
  // convert NamedNode/BlankNode object to JSON-LD
40345
40789
  if(o.termType.endsWith('Node')) {
40346
40790
  return {'@id': o.value};
@@ -40351,6 +40795,22 @@ function _RDFToObject(o, useNativeTypes, rdfDirection) {
40351
40795
 
40352
40796
  // add language
40353
40797
  if(o.language) {
40798
+ if(!o.language.match(REGEX_BCP47)) {
40799
+ if(options.eventHandler) {
40800
+ _handleEvent({
40801
+ event: {
40802
+ type: ['JsonLdEvent'],
40803
+ code: 'invalid @language value',
40804
+ level: 'warning',
40805
+ message: '@language value must be valid BCP47.',
40806
+ details: {
40807
+ language: o.language
40808
+ }
40809
+ },
40810
+ options
40811
+ });
40812
+ }
40813
+ }
40354
40814
  rval['@language'] = o.language;
40355
40815
  } else {
40356
40816
  let type = o.datatype.value;
@@ -40396,7 +40856,20 @@ function _RDFToObject(o, useNativeTypes, rdfDirection) {
40396
40856
  if(language.length > 0) {
40397
40857
  rval['@language'] = language;
40398
40858
  if(!language.match(REGEX_BCP47)) {
40399
- console.warn(`@language must be valid BCP47: ${language}`);
40859
+ if(options.eventHandler) {
40860
+ _handleEvent({
40861
+ event: {
40862
+ type: ['JsonLdEvent'],
40863
+ code: 'invalid @language value',
40864
+ level: 'warning',
40865
+ message: '@language value must be valid BCP47.',
40866
+ details: {
40867
+ language
40868
+ }
40869
+ },
40870
+ options
40871
+ });
40872
+ }
40400
40873
  }
40401
40874
  }
40402
40875
  rval['@direction'] = direction;
@@ -40526,11 +40999,12 @@ api.isSimpleGraph = v => {
40526
40999
  api.isBlankNode = v => {
40527
41000
  // Note: A value is a blank node if all of these hold true:
40528
41001
  // 1. It is an Object.
40529
- // 2. If it has an @id key its value begins with '_:'.
41002
+ // 2. If it has an @id key that is not a string OR begins with '_:'.
40530
41003
  // 3. It has no keys OR is not a @value, @set, or @list.
40531
41004
  if(types.isObject(v)) {
40532
41005
  if('@id' in v) {
40533
- return (v['@id'].indexOf('_:') === 0);
41006
+ const id = v['@id'];
41007
+ return !types.isString(id) || id.indexOf('_:') === 0;
40534
41008
  }
40535
41009
  return (Object.keys(v).length === 0 ||
40536
41010
  !(('@value' in v) || ('@set' in v) || ('@list' in v)));
@@ -40553,7 +41027,7 @@ api.isBlankNode = v => {
40553
41027
  * @author Dave Longley
40554
41028
  *
40555
41029
  * @license BSD 3-Clause License
40556
- * Copyright (c) 2011-2019 Digital Bazaar, Inc.
41030
+ * Copyright (c) 2011-2022 Digital Bazaar, Inc.
40557
41031
  * All rights reserved.
40558
41032
  *
40559
41033
  * Redistribution and use in source and binary forms, with or without
@@ -40629,6 +41103,16 @@ const {
40629
41103
  mergeNodeMaps: _mergeNodeMaps
40630
41104
  } = __webpack_require__(/*! ./nodeMap */ "./node_modules/jsonld/lib/nodeMap.js");
40631
41105
 
41106
+ const {
41107
+ logEventHandler: _logEventHandler,
41108
+ logWarningEventHandler: _logWarningEventHandler,
41109
+ safeEventHandler: _safeEventHandler,
41110
+ setDefaultEventHandler: _setDefaultEventHandler,
41111
+ setupEventHandler: _setupEventHandler,
41112
+ strictEventHandler: _strictEventHandler,
41113
+ unhandledEventHandler: _unhandledEventHandler
41114
+ } = __webpack_require__(/*! ./events */ "./node_modules/jsonld/lib/events.js");
41115
+
40632
41116
  /* eslint-disable indent */
40633
41117
  // attaches jsonld API to the given object
40634
41118
  const wrapper = function(jsonld) {
@@ -40659,15 +41143,8 @@ const _resolvedContextCache = new LRU({max: RESOLVED_CONTEXT_CACHE_MAX_SIZE});
40659
41143
  * [skipExpansion] true to assume the input is expanded and skip
40660
41144
  * expansion, false not to, defaults to false.
40661
41145
  * [documentLoader(url, options)] the document loader.
40662
- * [expansionMap(info)] a function that can be used to custom map
40663
- * unmappable values (or to throw an error when they are detected);
40664
- * if this function returns `undefined` then the default behavior
40665
- * will be used.
40666
41146
  * [framing] true if compaction is occuring during a framing operation.
40667
- * [compactionMap(info)] a function that can be used to custom map
40668
- * unmappable values (or to throw an error when they are detected);
40669
- * if this function returns `undefined` then the default behavior
40670
- * will be used.
41147
+ * [safe] true to use safe mode. (default: false)
40671
41148
  * [contextResolver] internal use only.
40672
41149
  *
40673
41150
  * @return a Promise that resolves to the compacted output.
@@ -40725,8 +41202,7 @@ jsonld.compact = async function(input, ctx, options) {
40725
41202
  let compacted = await _compact({
40726
41203
  activeCtx,
40727
41204
  element: expanded,
40728
- options,
40729
- compactionMap: options.compactionMap
41205
+ options
40730
41206
  });
40731
41207
 
40732
41208
  // perform clean up
@@ -40802,10 +41278,7 @@ jsonld.compact = async function(input, ctx, options) {
40802
41278
  * [keepFreeFloatingNodes] true to keep free-floating nodes,
40803
41279
  * false not to, defaults to false.
40804
41280
  * [documentLoader(url, options)] the document loader.
40805
- * [expansionMap(info)] a function that can be used to custom map
40806
- * unmappable values (or to throw an error when they are detected);
40807
- * if this function returns `undefined` then the default behavior
40808
- * will be used.
41281
+ * [safe] true to use safe mode. (default: false)
40809
41282
  * [contextResolver] internal use only.
40810
41283
  *
40811
41284
  * @return a Promise that resolves to the expanded output.
@@ -40821,9 +41294,6 @@ jsonld.expand = async function(input, options) {
40821
41294
  contextResolver: new ContextResolver(
40822
41295
  {sharedCache: _resolvedContextCache})
40823
41296
  });
40824
- if(options.expansionMap === false) {
40825
- options.expansionMap = undefined;
40826
- }
40827
41297
 
40828
41298
  // build set of objects that may have @contexts to resolve
40829
41299
  const toResolve = {};
@@ -40874,8 +41344,7 @@ jsonld.expand = async function(input, options) {
40874
41344
  let expanded = await _expand({
40875
41345
  activeCtx,
40876
41346
  element: toResolve.input,
40877
- options,
40878
- expansionMap: options.expansionMap
41347
+ options
40879
41348
  });
40880
41349
 
40881
41350
  // optimize away @graph with no other properties
@@ -40958,6 +41427,7 @@ jsonld.flatten = async function(input, ctx, options) {
40958
41427
  * [requireAll] default @requireAll flag (default: true).
40959
41428
  * [omitDefault] default @omitDefault flag (default: false).
40960
41429
  * [documentLoader(url, options)] the document loader.
41430
+ * [safe] true to use safe mode. (default: false)
40961
41431
  * [contextResolver] internal use only.
40962
41432
  *
40963
41433
  * @return a Promise that resolves to the framed output.
@@ -41056,6 +41526,7 @@ jsonld.frame = async function(input, frame, options) {
41056
41526
  * [base] the base IRI to use.
41057
41527
  * [expandContext] a context to expand with.
41058
41528
  * [documentLoader(url, options)] the document loader.
41529
+ * [safe] true to use safe mode. (default: false)
41059
41530
  * [contextResolver] internal use only.
41060
41531
  *
41061
41532
  * @return a Promise that resolves to the linked output.
@@ -41076,12 +41547,18 @@ jsonld.link = async function(input, ctx, options) {
41076
41547
  * unless the 'inputFormat' option is used. The output is an RDF dataset
41077
41548
  * unless the 'format' option is used.
41078
41549
  *
41550
+ * Note: Canonicalization sets `safe` to `true` and `base` to `null` by
41551
+ * default in order to produce safe outputs and "fail closed" by default. This
41552
+ * is different from the other API transformations in this version which
41553
+ * allow unsafe defaults (for cryptographic usage) in order to comply with the
41554
+ * JSON-LD 1.1 specification.
41555
+ *
41079
41556
  * @param input the input to normalize as JSON-LD or as a format specified by
41080
41557
  * the 'inputFormat' option.
41081
41558
  * @param [options] the options to use:
41082
41559
  * [algorithm] the normalization algorithm to use, `URDNA2015` or
41083
41560
  * `URGNA2012` (default: `URDNA2015`).
41084
- * [base] the base IRI to use.
41561
+ * [base] the base IRI to use (default: `null`).
41085
41562
  * [expandContext] a context to expand with.
41086
41563
  * [skipExpansion] true to assume the input is expanded and skip
41087
41564
  * expansion, false not to, defaults to false.
@@ -41091,6 +41568,7 @@ jsonld.link = async function(input, ctx, options) {
41091
41568
  * 'application/n-quads' for N-Quads.
41092
41569
  * [documentLoader(url, options)] the document loader.
41093
41570
  * [useNative] true to use a native canonize algorithm
41571
+ * [safe] true to use safe mode. (default: true).
41094
41572
  * [contextResolver] internal use only.
41095
41573
  *
41096
41574
  * @return a Promise that resolves to the normalized output.
@@ -41102,9 +41580,10 @@ jsonld.normalize = jsonld.canonize = async function(input, options) {
41102
41580
 
41103
41581
  // set default options
41104
41582
  options = _setDefaults(options, {
41105
- base: _isString(input) ? input : '',
41583
+ base: _isString(input) ? input : null,
41106
41584
  algorithm: 'URDNA2015',
41107
41585
  skipExpansion: false,
41586
+ safe: true,
41108
41587
  contextResolver: new ContextResolver(
41109
41588
  {sharedCache: _resolvedContextCache})
41110
41589
  });
@@ -41145,6 +41624,9 @@ jsonld.normalize = jsonld.canonize = async function(input, options) {
41145
41624
  * (default: false).
41146
41625
  * [useNativeTypes] true to convert XSD types into native types
41147
41626
  * (boolean, integer, double), false not to (default: false).
41627
+ * [rdfDirection] 'i18n-datatype' to support RDF transformation of
41628
+ * @direction (default: null).
41629
+ * [safe] true to use safe mode. (default: false)
41148
41630
  *
41149
41631
  * @return a Promise that resolves to the JSON-LD document.
41150
41632
  */
@@ -41194,6 +41676,7 @@ jsonld.fromRDF = async function(dataset, options) {
41194
41676
  * [produceGeneralizedRdf] true to output generalized RDF, false
41195
41677
  * to produce only standard RDF (default: false).
41196
41678
  * [documentLoader(url, options)] the document loader.
41679
+ * [safe] true to use safe mode. (default: false)
41197
41680
  * [contextResolver] internal use only.
41198
41681
  *
41199
41682
  * @return a Promise that resolves to the RDF dataset.
@@ -41286,6 +41769,7 @@ jsonld.createNodeMap = async function(input, options) {
41286
41769
  * new properties where a node is in the `object` position
41287
41770
  * (default: true).
41288
41771
  * [documentLoader(url, options)] the document loader.
41772
+ * [safe] true to use safe mode. (default: false)
41289
41773
  * [contextResolver] internal use only.
41290
41774
  *
41291
41775
  * @return a Promise that resolves to the merged output.
@@ -41448,6 +41932,7 @@ jsonld.get = async function(url, options) {
41448
41932
  * @param localCtx the local context to process.
41449
41933
  * @param [options] the options to use:
41450
41934
  * [documentLoader(url, options)] the document loader.
41935
+ * [safe] true to use safe mode. (default: false)
41451
41936
  * [contextResolver] internal use only.
41452
41937
  *
41453
41938
  * @return a Promise that resolves to the new active context.
@@ -41533,6 +42018,14 @@ jsonld.registerRDFParser('application/nquads', NQuads.parse);
41533
42018
  /* URL API */
41534
42019
  jsonld.url = __webpack_require__(/*! ./url */ "./node_modules/jsonld/lib/url.js");
41535
42020
 
42021
+ /* Events API and handlers */
42022
+ jsonld.logEventHandler = _logEventHandler;
42023
+ jsonld.logWarningEventHandler = _logWarningEventHandler;
42024
+ jsonld.safeEventHandler = _safeEventHandler;
42025
+ jsonld.setDefaultEventHandler = _setDefaultEventHandler;
42026
+ jsonld.strictEventHandler = _strictEventHandler;
42027
+ jsonld.unhandledEventHandler = _unhandledEventHandler;
42028
+
41536
42029
  /* Utility API */
41537
42030
  jsonld.util = util;
41538
42031
  // backwards compatibility
@@ -41554,7 +42047,24 @@ function _setDefaults(options, {
41554
42047
  documentLoader = jsonld.documentLoader,
41555
42048
  ...defaults
41556
42049
  }) {
41557
- return Object.assign({}, {documentLoader}, defaults, options);
42050
+ // fail if obsolete options present
42051
+ if(options && 'compactionMap' in options) {
42052
+ throw new JsonLdError(
42053
+ '"compactionMap" not supported.',
42054
+ 'jsonld.OptionsError');
42055
+ }
42056
+ if(options && 'expansionMap' in options) {
42057
+ throw new JsonLdError(
42058
+ '"expansionMap" not supported.',
42059
+ 'jsonld.OptionsError');
42060
+ }
42061
+ return Object.assign(
42062
+ {},
42063
+ {documentLoader},
42064
+ defaults,
42065
+ options,
42066
+ {eventHandler: _setupEventHandler({options})}
42067
+ );
41558
42068
  }
41559
42069
 
41560
42070
  // end of jsonld API `wrapper` factory
@@ -41948,6 +42458,10 @@ const jsonCanonicalize = __webpack_require__(/*! canonicalize */ "./node_modules
41948
42458
  const types = __webpack_require__(/*! ./types */ "./node_modules/jsonld/lib/types.js");
41949
42459
  const util = __webpack_require__(/*! ./util */ "./node_modules/jsonld/lib/util.js");
41950
42460
 
42461
+ const {
42462
+ handleEvent: _handleEvent
42463
+ } = __webpack_require__(/*! ./events */ "./node_modules/jsonld/lib/events.js");
42464
+
41951
42465
  const {
41952
42466
  // RDF,
41953
42467
  // RDF_LIST,
@@ -42004,6 +42518,20 @@ api.toRDF = (input, options) => {
42004
42518
  graphTerm.value = graphName;
42005
42519
  } else {
42006
42520
  // skip relative IRIs (not valid RDF)
42521
+ if(options.eventHandler) {
42522
+ _handleEvent({
42523
+ event: {
42524
+ type: ['JsonLdEvent'],
42525
+ code: 'relative graph reference',
42526
+ level: 'warning',
42527
+ message: 'Relative graph reference found.',
42528
+ details: {
42529
+ graph: graphName
42530
+ }
42531
+ },
42532
+ options
42533
+ });
42534
+ }
42007
42535
  continue;
42008
42536
  }
42009
42537
  _graphToRDF(dataset, nodeMap[graphName], graphTerm, issuer, options);
@@ -42045,6 +42573,20 @@ function _graphToRDF(dataset, graph, graphTerm, issuer, options) {
42045
42573
 
42046
42574
  // skip relative IRI subjects (not valid RDF)
42047
42575
  if(!_isAbsoluteIri(id)) {
42576
+ if(options.eventHandler) {
42577
+ _handleEvent({
42578
+ event: {
42579
+ type: ['JsonLdEvent'],
42580
+ code: 'relative subject reference',
42581
+ level: 'warning',
42582
+ message: 'Relative subject reference found.',
42583
+ details: {
42584
+ subject: id
42585
+ }
42586
+ },
42587
+ options
42588
+ });
42589
+ }
42048
42590
  continue;
42049
42591
  }
42050
42592
 
@@ -42056,18 +42598,48 @@ function _graphToRDF(dataset, graph, graphTerm, issuer, options) {
42056
42598
 
42057
42599
  // skip relative IRI predicates (not valid RDF)
42058
42600
  if(!_isAbsoluteIri(property)) {
42601
+ if(options.eventHandler) {
42602
+ _handleEvent({
42603
+ event: {
42604
+ type: ['JsonLdEvent'],
42605
+ code: 'relative predicate reference',
42606
+ level: 'warning',
42607
+ message: 'Relative predicate reference found.',
42608
+ details: {
42609
+ predicate: property
42610
+ }
42611
+ },
42612
+ options
42613
+ });
42614
+ }
42059
42615
  continue;
42060
42616
  }
42061
42617
 
42062
42618
  // skip blank node predicates unless producing generalized RDF
42063
42619
  if(predicate.termType === 'BlankNode' &&
42064
42620
  !options.produceGeneralizedRdf) {
42621
+ if(options.eventHandler) {
42622
+ _handleEvent({
42623
+ event: {
42624
+ type: ['JsonLdEvent'],
42625
+ code: 'blank node predicate',
42626
+ level: 'warning',
42627
+ message: 'Dropping blank node predicate.',
42628
+ details: {
42629
+ // FIXME: add better issuer API to get reverse mapping
42630
+ property: issuer.getOldIds()
42631
+ .find(key => issuer.getId(key) === property)
42632
+ }
42633
+ },
42634
+ options
42635
+ });
42636
+ }
42065
42637
  continue;
42066
42638
  }
42067
42639
 
42068
42640
  // convert list, value or node object to triple
42069
- const object =
42070
- _objectToRDF(item, issuer, dataset, graphTerm, options.rdfDirection);
42641
+ const object = _objectToRDF(
42642
+ item, issuer, dataset, graphTerm, options.rdfDirection, options);
42071
42643
  // skip null objects (they are relative IRIs)
42072
42644
  if(object) {
42073
42645
  dataset.push({
@@ -42090,10 +42662,11 @@ function _graphToRDF(dataset, graph, graphTerm, issuer, options) {
42090
42662
  * @param issuer a IdentifierIssuer for assigning blank node names.
42091
42663
  * @param dataset the array of quads to append to.
42092
42664
  * @param graphTerm the graph term for each quad.
42665
+ * @param options the RDF serialization options.
42093
42666
  *
42094
42667
  * @return the head of the list.
42095
42668
  */
42096
- function _listToRDF(list, issuer, dataset, graphTerm, rdfDirection) {
42669
+ function _listToRDF(list, issuer, dataset, graphTerm, rdfDirection, options) {
42097
42670
  const first = {termType: 'NamedNode', value: RDF_FIRST};
42098
42671
  const rest = {termType: 'NamedNode', value: RDF_REST};
42099
42672
  const nil = {termType: 'NamedNode', value: RDF_NIL};
@@ -42104,7 +42677,8 @@ function _listToRDF(list, issuer, dataset, graphTerm, rdfDirection) {
42104
42677
  let subject = result;
42105
42678
 
42106
42679
  for(const item of list) {
42107
- const object = _objectToRDF(item, issuer, dataset, graphTerm, rdfDirection);
42680
+ const object = _objectToRDF(
42681
+ item, issuer, dataset, graphTerm, rdfDirection, options);
42108
42682
  const next = {termType: 'BlankNode', value: issuer.getId()};
42109
42683
  dataset.push({
42110
42684
  subject,
@@ -42123,7 +42697,8 @@ function _listToRDF(list, issuer, dataset, graphTerm, rdfDirection) {
42123
42697
 
42124
42698
  // Tail of list
42125
42699
  if(last) {
42126
- const object = _objectToRDF(last, issuer, dataset, graphTerm, rdfDirection);
42700
+ const object = _objectToRDF(
42701
+ last, issuer, dataset, graphTerm, rdfDirection, options);
42127
42702
  dataset.push({
42128
42703
  subject,
42129
42704
  predicate: first,
@@ -42149,10 +42724,13 @@ function _listToRDF(list, issuer, dataset, graphTerm, rdfDirection) {
42149
42724
  * @param issuer a IdentifierIssuer for assigning blank node names.
42150
42725
  * @param dataset the dataset to append RDF quads to.
42151
42726
  * @param graphTerm the graph term for each quad.
42727
+ * @param options the RDF serialization options.
42152
42728
  *
42153
42729
  * @return the RDF literal or RDF resource.
42154
42730
  */
42155
- function _objectToRDF(item, issuer, dataset, graphTerm, rdfDirection) {
42731
+ function _objectToRDF(
42732
+ item, issuer, dataset, graphTerm, rdfDirection, options
42733
+ ) {
42156
42734
  const object = {};
42157
42735
 
42158
42736
  // convert value object to RDF
@@ -42198,8 +42776,8 @@ function _objectToRDF(item, issuer, dataset, graphTerm, rdfDirection) {
42198
42776
  object.datatype.value = datatype || XSD_STRING;
42199
42777
  }
42200
42778
  } else if(graphTypes.isList(item)) {
42201
- const _list =
42202
- _listToRDF(item['@list'], issuer, dataset, graphTerm, rdfDirection);
42779
+ const _list = _listToRDF(
42780
+ item['@list'], issuer, dataset, graphTerm, rdfDirection, options);
42203
42781
  object.termType = _list.termType;
42204
42782
  object.value = _list.value;
42205
42783
  } else {
@@ -42211,6 +42789,20 @@ function _objectToRDF(item, issuer, dataset, graphTerm, rdfDirection) {
42211
42789
 
42212
42790
  // skip relative IRIs, not valid RDF
42213
42791
  if(object.termType === 'NamedNode' && !_isAbsoluteIri(object.value)) {
42792
+ if(options.eventHandler) {
42793
+ _handleEvent({
42794
+ event: {
42795
+ type: ['JsonLdEvent'],
42796
+ code: 'relative object reference',
42797
+ level: 'warning',
42798
+ message: 'Relative object reference found.',
42799
+ details: {
42800
+ object: object.value
42801
+ }
42802
+ },
42803
+ options
42804
+ });
42805
+ }
42214
42806
  return null;
42215
42807
  }
42216
42808
 
@@ -42654,10 +43246,12 @@ const IdentifierIssuer = (__webpack_require__(/*! rdf-canonize */ "./node_module
42654
43246
  const JsonLdError = __webpack_require__(/*! ./JsonLdError */ "./node_modules/jsonld/lib/JsonLdError.js");
42655
43247
 
42656
43248
  // constants
43249
+ const REGEX_BCP47 = /^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/;
42657
43250
  const REGEX_LINK_HEADERS = /(?:<[^>]*?>|"[^"]*?"|[^,])+/g;
42658
43251
  const REGEX_LINK_HEADER = /\s*<([^>]*?)>\s*(?:;\s*(.*))?/;
42659
43252
  const REGEX_LINK_HEADER_PARAMS =
42660
43253
  /(.*?)=(?:(?:"([^"]*?)")|([^"]*?))\s*(?:(?:;\s*)|$)/g;
43254
+ const REGEX_KEYWORD = /^@[a-zA-Z]+$/;
42661
43255
 
42662
43256
  const DEFAULTS = {
42663
43257
  headers: {
@@ -42668,6 +43262,8 @@ const DEFAULTS = {
42668
43262
  const api = {};
42669
43263
  module.exports = api;
42670
43264
  api.IdentifierIssuer = IdentifierIssuer;
43265
+ api.REGEX_BCP47 = REGEX_BCP47;
43266
+ api.REGEX_KEYWORD = REGEX_KEYWORD;
42671
43267
 
42672
43268
  /**
42673
43269
  * Clones an object, array, Map, Set, or string/number. If a typed JavaScript
@@ -42774,7 +43370,7 @@ api.parseLinkHeader = header => {
42774
43370
  while((match = REGEX_LINK_HEADER_PARAMS.exec(params))) {
42775
43371
  result[match[1]] = (match[2] === undefined) ? match[3] : match[2];
42776
43372
  }
42777
- const rel = result['rel'] || '';
43373
+ const rel = result.rel || '';
42778
43374
  if(Array.isArray(rval[rel])) {
42779
43375
  rval[rel].push(result);
42780
43376
  } else if(rval.hasOwnProperty(rel)) {
@@ -52440,10 +53036,11 @@ var Collection = /*#__PURE__*/function (_Node) {
52440
53036
  }, {
52441
53037
  key: "substitute",
52442
53038
  value: function substitute(bindings) {
52443
- var elementsCopy = this.elements.map(function (ea) {
52444
- return ea.substitute(bindings);
53039
+ var collection = new Collection();
53040
+ this.elements.forEach(function (ea) {
53041
+ collection.append(ea.substitute(bindings));
52445
53042
  });
52446
- return new Collection(elementsCopy);
53043
+ return collection;
52447
53044
  }
52448
53045
  }, {
52449
53046
  key: "toNT",
@@ -54280,16 +54877,17 @@ var Fetcher = /*#__PURE__*/function () {
54280
54877
  var fetcher = this;
54281
54878
  // @ts-ignore
54282
54879
  if (fetcher.fetchQueue && fetcher.fetchQueue[uri]) {
54283
- console.log('Internal error - fetchQueue exists ' + uri);
54880
+ // console.log('Internal error - fetchQueue exists ' + uri)
54284
54881
  var promise = fetcher.fetchQueue[uri];
54285
54882
  if (promise['PromiseStatus'] === 'resolved') {
54286
54883
  delete fetcher.fetchQueue[uri];
54287
54884
  } else {
54288
54885
  // pending
54289
54886
  delete fetcher.fetchQueue[uri];
54290
- console.log('*** Fetcher: pending fetchQueue deleted ' + uri);
54887
+ // console.log('*** Fetcher: pending fetchQueue deleted ' + uri)
54291
54888
  }
54292
54889
  }
54890
+
54293
54891
  if (fetcher.requested[uri] && fetcher.requested[uri] !== 'done' && fetcher.requested[uri] !== 'failed' && fetcher.requested[uri] !== 404) {
54294
54892
  var msg = "Rdflib: fetcher: Destructive operation on <".concat(fetcher.requested[uri], "> file being fetched! ") + uri;
54295
54893
  console.error(msg);
@@ -56154,6 +56752,9 @@ function jsonldParser(str, kb, base, callback) {
56154
56752
  var baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base;
56155
56753
  return jsonld__WEBPACK_IMPORTED_MODULE_0___default().flatten(JSON.parse(str), null, {
56156
56754
  base: baseString
56755
+ }).then(function (flattened) {
56756
+ console.log(flattened);
56757
+ return flattened;
56157
56758
  }).then(function (flattened) {
56158
56759
  return flattened.reduce(function (store, flatResource) {
56159
56760
  kb = processResource(kb, base, flatResource);
@@ -61241,7 +61842,7 @@ contentType, callback, options) {
61241
61842
  documentString = sz.statementsToNTriples(newSts);
61242
61843
  return executeCallback(null, documentString);
61243
61844
  case _types__WEBPACK_IMPORTED_MODULE_0__.JSONLDContentType:
61244
- sz.setFlags('si'); // use turtle parameters
61845
+ sz.setFlags('si dr'); // turtle + dr (means no default, no relative prefix)
61245
61846
  documentString = sz.statementsToJsonld(newSts); // convert via turtle
61246
61847
  return executeCallback(null, documentString);
61247
61848
  case _types__WEBPACK_IMPORTED_MODULE_0__.NQuadsContentType:
@@ -61313,7 +61914,6 @@ __webpack_require__.r(__webpack_exports__);
61313
61914
 
61314
61915
 
61315
61916
 
61316
- // import * as jsonld from 'jsonld'
61317
61917
 
61318
61918
  function createSerializer(store) {
61319
61919
  return new Serializer(store);
@@ -61820,7 +62420,7 @@ var Serializer = /*#__PURE__*/function () {
61820
62420
  var termToN3 = termToN3Method.bind(this);
61821
62421
  function prefixDirectivesMethod() {
61822
62422
  var str = '';
61823
- if (this.defaultNamespace) {
62423
+ if (this.flags.indexOf('d') < 0 && this.defaultNamespace) {
61824
62424
  str += '@prefix : ' + this.explicitURI(this.defaultNamespace) + '.\n';
61825
62425
  }
61826
62426
  for (var ns in this.prefixes) {
@@ -62305,20 +62905,19 @@ var Serializer = /*#__PURE__*/function () {
62305
62905
  key: "statementsToJsonld",
62306
62906
  value: function statementsToJsonld(sts) {
62307
62907
  // ttl2jsonld creates context keys for all ttl prefix
62308
- // context keys must be full IRI
62309
- function findId(itemObj) {
62908
+ // context keys must be absolute IRI ttl2jsonld@0.0.8
62909
+ /* function findId (itemObj) {
62310
62910
  if (itemObj['@id']) {
62311
- var item = itemObj['@id'].split(':');
62312
- if (keys[item[0]]) itemObj['@id'] = jsonldObj['@context'][item[0]] + item[1];
62911
+ const item = itemObj['@id'].split(':')
62912
+ if (keys[item[0]]) itemObj['@id'] = jsonldObj['@context'][item[0]] + item[1]
62313
62913
  }
62314
- var itemValues = Object.values(itemObj);
62315
- for (var i in itemValues) {
62316
- if (typeof itemValues[i] !== 'string') {
62317
- // @list contains array
62318
- findId(itemValues[i]);
62914
+ const itemValues = Object.values(itemObj)
62915
+ for (const i in itemValues) {
62916
+ if (typeof itemValues[i] !== 'string') { // @list contains array
62917
+ findId(itemValues[i])
62319
62918
  }
62320
62919
  }
62321
- }
62920
+ } */
62322
62921
  var turtleDoc = this.statementsToN3(sts);
62323
62922
  var jsonldObj = _frogcat_ttl2jsonld__WEBPACK_IMPORTED_MODULE_4__.parse(turtleDoc);
62324
62923
  return JSON.stringify(jsonldObj, null, 2);
@@ -63257,9 +63856,9 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
63257
63856
  // console.log('ds before substitute: ' + ds)
63258
63857
  if (binding) ds = ds.substitute(binding);
63259
63858
  // console.log('applyPatch: delete: ' + ds)
63260
- ds = ds.statements;
63859
+
63261
63860
  var bad = [];
63262
- var ds2 = ds.map(function (st) {
63861
+ var ds2 = ds.elements.map(function (st) {
63263
63862
  // Find the actual statements in the store
63264
63863
  var sts = targetKB.statementsMatching(st.subject, st.predicate, st.object, target);
63265
63864
  if (sts.length === 0) {
@@ -63284,8 +63883,7 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
63284
63883
  // log.info("doPatch insert "+patch['insert'])
63285
63884
  ds = patch['insert'];
63286
63885
  if (binding) ds = ds.substitute(binding);
63287
- ds = ds.statements;
63288
- ds.map(function (st) {
63886
+ ds.elements.map(function (st) {
63289
63887
  st.graph = target;
63290
63888
  targetKB.add(st.subject, st.predicate, st.object, st.graph);
63291
63889
  });
@@ -63302,6 +63900,7 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
63302
63900
  //@ts-ignore TODO: add sync property to Query when converting Query to typescript
63303
63901
  query.sync = true;
63304
63902
  var bindingsFound = [];
63903
+ query.pat.initBindings = [];
63305
63904
  targetKB.query(query, function onBinding(binding) {
63306
63905
  bindingsFound.push(binding);
63307
63906
  // console.log(' got a binding: ' + bindingDebug(binding))
@@ -66820,15 +67419,13 @@ function createAclLogic(store) {
66820
67419
  var ns = ns_1.ns;
66821
67420
  function findAclDocUrl(url) {
66822
67421
  return __awaiter(this, void 0, void 0, function () {
66823
- var doc, docNode;
67422
+ var docNode;
66824
67423
  return __generator(this, function (_a) {
66825
67424
  switch (_a.label) {
66826
- case 0:
66827
- doc = store.sym(url);
66828
- return [4 /*yield*/, store.fetcher.load(doc)];
67425
+ case 0: return [4 /*yield*/, store.fetcher.load(url)];
66829
67426
  case 1:
66830
67427
  _a.sent();
66831
- docNode = store.any(doc, exports.ACL_LINK);
67428
+ docNode = store.any(url, exports.ACL_LINK);
66832
67429
  if (!docNode) {
66833
67430
  throw new Error("No ACL link discovered for ".concat(url));
66834
67431
  }
@@ -67636,7 +68233,7 @@ function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, acl
67636
68233
  case 2: return [4 /*yield*/, profileLogic.getMainInbox(user)];
67637
68234
  case 3:
67638
68235
  inbox = _a.sent();
67639
- return [4 /*yield*/, containerLogic.getContainerMembers(inbox.value)];
68236
+ return [4 /*yield*/, containerLogic.getContainerMembers(inbox)];
67640
68237
  case 4:
67641
68238
  urls = _a.sent();
67642
68239
  return [2 /*return*/, urls.filter(function (url) { return !containerLogic.isContainer(url); })];
@@ -68792,19 +69389,21 @@ var rdflib_1 = __webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/inde
68792
69389
  function createContainerLogic(store) {
68793
69390
  function getContainerElements(containerNode) {
68794
69391
  return store
68795
- .statementsMatching(containerNode, (0, rdflib_1.sym)("http://www.w3.org/ns/ldp#contains"), undefined, containerNode.doc())
69392
+ .statementsMatching(containerNode, (0, rdflib_1.sym)("http://www.w3.org/ns/ldp#contains"), undefined)
68796
69393
  .map(function (st) { return st.object; });
68797
69394
  }
68798
69395
  function isContainer(url) {
68799
- return url.charAt(url.length - 1) === "/";
69396
+ var nodeToString = url.value;
69397
+ return nodeToString.charAt(nodeToString.length - 1) === "/";
68800
69398
  }
68801
69399
  function createContainer(url) {
68802
69400
  return __awaiter(this, void 0, void 0, function () {
68803
- var result;
69401
+ var stringToNode, result;
68804
69402
  return __generator(this, function (_a) {
68805
69403
  switch (_a.label) {
68806
69404
  case 0:
68807
- if (!isContainer(url)) {
69405
+ stringToNode = (0, rdflib_1.sym)(url);
69406
+ if (!isContainer(stringToNode)) {
68808
69407
  throw new Error("Not a container URL ".concat(url));
68809
69408
  }
68810
69409
  return [4 /*yield*/, store.fetcher._fetch(url, {
@@ -68828,16 +69427,12 @@ function createContainerLogic(store) {
68828
69427
  }
68829
69428
  function getContainerMembers(containerUrl) {
68830
69429
  return __awaiter(this, void 0, void 0, function () {
68831
- var containerNode, nodes;
68832
69430
  return __generator(this, function (_a) {
68833
69431
  switch (_a.label) {
68834
- case 0:
68835
- containerNode = store.sym(containerUrl);
68836
- return [4 /*yield*/, store.fetcher.load(containerNode)];
69432
+ case 0: return [4 /*yield*/, store.fetcher.load(containerUrl)];
68837
69433
  case 1:
68838
69434
  _a.sent();
68839
- nodes = getContainerElements(containerNode);
68840
- return [2 /*return*/, nodes.map(function (node) { return node.value; })];
69435
+ return [2 /*return*/, getContainerElements(containerUrl)];
68841
69436
  }
68842
69437
  });
68843
69438
  });
@@ -69023,28 +69618,30 @@ var CustomError_1 = __webpack_require__(/*! ../logic/CustomError */ "./node_modu
69023
69618
  var debug = __importStar(__webpack_require__(/*! ../util/debug */ "./node_modules/solid-logic/lib/util/debug.js"));
69024
69619
  var utils_1 = __webpack_require__(/*! ./utils */ "./node_modules/solid-logic/lib/util/utils.js");
69025
69620
  function createUtilityLogic(store, aclLogic, containerLogic) {
69026
- function recursiveDelete(url) {
69621
+ function recursiveDelete(containerNode) {
69027
69622
  return __awaiter(this, void 0, void 0, function () {
69028
- var aclDocUrl, containerMembers, e_1;
69623
+ var aclDocUrl, containerMembers, nodeToStringHere, e_1;
69029
69624
  return __generator(this, function (_a) {
69030
69625
  switch (_a.label) {
69031
69626
  case 0:
69032
69627
  _a.trys.push([0, 6, , 7]);
69033
- if (!containerLogic.isContainer(url)) return [3 /*break*/, 5];
69034
- return [4 /*yield*/, aclLogic.findAclDocUrl(url)];
69628
+ if (!containerLogic.isContainer(containerNode)) return [3 /*break*/, 5];
69629
+ return [4 /*yield*/, aclLogic.findAclDocUrl(containerNode)];
69035
69630
  case 1:
69036
69631
  aclDocUrl = _a.sent();
69037
69632
  return [4 /*yield*/, store.fetcher._fetch(aclDocUrl, { method: "DELETE" })];
69038
69633
  case 2:
69039
69634
  _a.sent();
69040
- return [4 /*yield*/, containerLogic.getContainerMembers(url)];
69635
+ return [4 /*yield*/, containerLogic.getContainerMembers(containerNode)];
69041
69636
  case 3:
69042
69637
  containerMembers = _a.sent();
69043
69638
  return [4 /*yield*/, Promise.all(containerMembers.map(function (url) { return recursiveDelete(url); }))];
69044
69639
  case 4:
69045
69640
  _a.sent();
69046
69641
  _a.label = 5;
69047
- case 5: return [2 /*return*/, store.fetcher._fetch(url, { method: "DELETE" })];
69642
+ case 5:
69643
+ nodeToStringHere = containerNode.value;
69644
+ return [2 /*return*/, store.fetcher._fetch(nodeToStringHere, { method: "DELETE" })];
69048
69645
  case 6:
69049
69646
  e_1 = _a.sent();
69050
69647
  return [3 /*break*/, 7];
@@ -69189,7 +69786,7 @@ function createUtilityLogic(store, aclLogic, containerLogic) {
69189
69786
  ''
69190
69787
  ].join('\n');
69191
69788
  }
69192
- return [4 /*yield*/, aclLogic.findAclDocUrl(options.target)];
69789
+ return [4 /*yield*/, aclLogic.findAclDocUrl((0, rdflib_1.sym)(options.target))];
69193
69790
  case 1:
69194
69791
  aclDocUrl = _a.sent();
69195
69792
  return [2 /*return*/, store.fetcher._fetch(aclDocUrl, {
@@ -73561,6 +74158,7 @@ __webpack_require__.r(__webpack_exports__);
73561
74158
  /* harmony export */ "getWebidFromTokenPayload": () => (/* binding */ getWebidFromTokenPayload),
73562
74159
  /* harmony export */ "handleRegistration": () => (/* binding */ handleRegistration),
73563
74160
  /* harmony export */ "isSupportedTokenType": () => (/* binding */ isSupportedTokenType),
74161
+ /* harmony export */ "isValidRedirectUrl": () => (/* binding */ isValidRedirectUrl),
73564
74162
  /* harmony export */ "loadOidcContextFromStorage": () => (/* binding */ loadOidcContextFromStorage),
73565
74163
  /* harmony export */ "mockStorage": () => (/* binding */ mockStorage),
73566
74164
  /* harmony export */ "mockStorageUtility": () => (/* binding */ mockStorageUtility),
@@ -73667,6 +74265,16 @@ async function getWebidFromTokenPayload(idToken, jwksIri, issuerIri, clientId) {
73667
74265
  }
73668
74266
  }
73669
74267
 
74268
+ function isValidRedirectUrl(redirectUrl) {
74269
+ try {
74270
+ const urlObject = new URL(redirectUrl);
74271
+ return urlObject.hash === "";
74272
+ }
74273
+ catch (e) {
74274
+ return false;
74275
+ }
74276
+ }
74277
+
73670
74278
  function isSupportedTokenType(token) {
73671
74279
  return typeof token === "string" && ["DPoP", "Bearer"].includes(token);
73672
74280
  }
@@ -75036,7 +75644,7 @@ class LocalJWKSet {
75036
75644
  this._jwks = clone(jwks);
75037
75645
  }
75038
75646
  async getKey(protectedHeader, token) {
75039
- const { alg, kid } = { ...protectedHeader, ...token.header };
75647
+ const { alg, kid } = { ...protectedHeader, ...token === null || token === void 0 ? void 0 : token.header };
75040
75648
  const kty = getKtyFromAlg(alg);
75041
75649
  const candidates = this._jwks.keys.filter((jwk) => {
75042
75650
  let candidate = kty === jwk.kty;
@@ -75078,18 +75686,33 @@ class LocalJWKSet {
75078
75686
  throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSNoMatchingKey();
75079
75687
  }
75080
75688
  else if (length !== 1) {
75081
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSMultipleMatchingKeys();
75689
+ const error = new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSMultipleMatchingKeys();
75690
+ const { _cached } = this;
75691
+ error[Symbol.asyncIterator] = async function* () {
75692
+ for (const jwk of candidates) {
75693
+ try {
75694
+ yield await importWithAlgCache(_cached, jwk, alg);
75695
+ }
75696
+ catch (_a) {
75697
+ continue;
75698
+ }
75699
+ }
75700
+ };
75701
+ throw error;
75082
75702
  }
75083
- const cached = this._cached.get(jwk) || this._cached.set(jwk, {}).get(jwk);
75084
- if (cached[alg] === undefined) {
75085
- const keyObject = await (0,_key_import_js__WEBPACK_IMPORTED_MODULE_0__.importJWK)({ ...jwk, ext: true }, alg);
75086
- if (keyObject instanceof Uint8Array || keyObject.type !== 'public') {
75087
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSInvalid('JSON Web Key Set members must be public keys');
75088
- }
75089
- cached[alg] = keyObject;
75703
+ return importWithAlgCache(this._cached, jwk, alg);
75704
+ }
75705
+ }
75706
+ async function importWithAlgCache(cache, jwk, alg) {
75707
+ const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
75708
+ if (cached[alg] === undefined) {
75709
+ const keyObject = await (0,_key_import_js__WEBPACK_IMPORTED_MODULE_0__.importJWK)({ ...jwk, ext: true }, alg);
75710
+ if (keyObject.type !== 'public') {
75711
+ throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JWKSInvalid('JSON Web Key Set members must be public keys');
75090
75712
  }
75091
- return cached[alg];
75713
+ cached[alg] = keyObject;
75092
75714
  }
75715
+ return cached[alg];
75093
75716
  }
75094
75717
  function createLocalJWKSet(jwks) {
75095
75718
  return LocalJWKSet.prototype.getKey.bind(new LocalJWKSet(jwks));
@@ -76518,13 +77141,13 @@ function checkSigCryptoKey(key, alg, ...usages) {
76518
77141
  throw unusable(`SHA-${expected}`, 'algorithm.hash');
76519
77142
  break;
76520
77143
  }
76521
- case (0,_runtime_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && 'EdDSA': {
76522
- if (!isAlgorithm(key.algorithm, 'NODE-ED25519'))
76523
- throw unusable('NODE-ED25519');
76524
- break;
76525
- }
76526
77144
  case 'EdDSA': {
76527
77145
  if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {
77146
+ if ((0,_runtime_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
77147
+ if (isAlgorithm(key.algorithm, 'NODE-ED25519'))
77148
+ break;
77149
+ throw unusable('Ed25519, Ed448, or NODE-ED25519');
77150
+ }
76528
77151
  throw unusable('Ed25519 or Ed448');
76529
77152
  }
76530
77153
  break;
@@ -77409,7 +78032,7 @@ const getNamedCurve = (keyData) => {
77409
78032
  }
77410
78033
  };
77411
78034
  const genericImport = async (replace, keyFormat, pem, alg, options) => {
77412
- var _a;
78035
+ var _a, _b;
77413
78036
  let algorithm;
77414
78037
  let keyUsages;
77415
78038
  const keyData = new Uint8Array(atob(pem.replace(replace, ''))
@@ -77460,12 +78083,6 @@ const genericImport = async (replace, keyFormat, pem, alg, options) => {
77460
78083
  keyUsages = isPublic ? [] : ['deriveBits'];
77461
78084
  break;
77462
78085
  }
77463
- case (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && 'EdDSA': {
77464
- const namedCurve = getNamedCurve(keyData).toUpperCase();
77465
- algorithm = { name: `NODE-${namedCurve}`, namedCurve: `NODE-${namedCurve}` };
77466
- keyUsages = isPublic ? ['verify'] : ['sign'];
77467
- break;
77468
- }
77469
78086
  case 'EdDSA':
77470
78087
  algorithm = { name: getNamedCurve(keyData) };
77471
78088
  keyUsages = isPublic ? ['verify'] : ['sign'];
@@ -77473,7 +78090,18 @@ const genericImport = async (replace, keyFormat, pem, alg, options) => {
77473
78090
  default:
77474
78091
  throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_5__.JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
77475
78092
  }
77476
- return _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
78093
+ try {
78094
+ return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);
78095
+ }
78096
+ catch (err) {
78097
+ if (algorithm.name === 'Ed25519' &&
78098
+ (err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
78099
+ (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
78100
+ algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
78101
+ return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey(keyFormat, keyData, algorithm, (_b = options === null || options === void 0 ? void 0 : options.extractable) !== null && _b !== void 0 ? _b : false, keyUsages);
78102
+ }
78103
+ throw err;
78104
+ }
77477
78105
  };
77478
78106
  const fromPKCS8 = (pem, alg, options) => {
77479
78107
  return genericImport(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g, 'pkcs8', pem, alg, options);
@@ -78038,7 +78666,7 @@ function getModulusLengthOption(options) {
78038
78666
  return modulusLength;
78039
78667
  }
78040
78668
  async function generateKeyPair(alg, options) {
78041
- var _a, _b, _c;
78669
+ var _a, _b, _c, _d;
78042
78670
  let algorithm;
78043
78671
  let keyUsages;
78044
78672
  switch (alg) {
@@ -78088,17 +78716,6 @@ async function generateKeyPair(alg, options) {
78088
78716
  algorithm = { name: 'ECDSA', namedCurve: 'P-521' };
78089
78717
  keyUsages = ['sign', 'verify'];
78090
78718
  break;
78091
- case (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && 'EdDSA':
78092
- switch (options === null || options === void 0 ? void 0 : options.crv) {
78093
- case undefined:
78094
- case 'Ed25519':
78095
- algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
78096
- keyUsages = ['sign', 'verify'];
78097
- break;
78098
- default:
78099
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported crv option provided');
78100
- }
78101
- break;
78102
78719
  case 'EdDSA':
78103
78720
  keyUsages = ['sign', 'verify'];
78104
78721
  const crv = (_a = options === null || options === void 0 ? void 0 : options.crv) !== null && _a !== void 0 ? _a : 'Ed25519';
@@ -78136,7 +78753,18 @@ async function generateKeyPair(alg, options) {
78136
78753
  default:
78137
78754
  throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
78138
78755
  }
78139
- return (_webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
78756
+ try {
78757
+ return (await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));
78758
+ }
78759
+ catch (err) {
78760
+ if (algorithm.name === 'Ed25519' &&
78761
+ (err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
78762
+ (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
78763
+ algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
78764
+ return (await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.generateKey(algorithm, (_d = options === null || options === void 0 ? void 0 : options.extractable) !== null && _d !== void 0 ? _d : false, keyUsages));
78765
+ }
78766
+ throw err;
78767
+ }
78140
78768
  }
78141
78769
 
78142
78770
 
@@ -78316,19 +78944,6 @@ function subtleMapping(jwk) {
78316
78944
  }
78317
78945
  break;
78318
78946
  }
78319
- case (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && 'OKP':
78320
- if (jwk.alg !== 'EdDSA') {
78321
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
78322
- }
78323
- switch (jwk.crv) {
78324
- case 'Ed25519':
78325
- algorithm = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
78326
- keyUsages = jwk.d ? ['sign'] : ['verify'];
78327
- break;
78328
- default:
78329
- throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_2__.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
78330
- }
78331
- break;
78332
78947
  case 'OKP': {
78333
78948
  switch (jwk.alg) {
78334
78949
  case 'EdDSA':
@@ -78366,7 +78981,18 @@ const parse = async (jwk) => {
78366
78981
  const keyData = { ...jwk };
78367
78982
  delete keyData.alg;
78368
78983
  delete keyData.use;
78369
- return _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
78984
+ try {
78985
+ return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
78986
+ }
78987
+ catch (err) {
78988
+ if (algorithm.name === 'Ed25519' &&
78989
+ (err === null || err === void 0 ? void 0 : err.name) === 'NotSupportedError' &&
78990
+ (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)()) {
78991
+ rest[0] = { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
78992
+ return await _webcrypto_js__WEBPACK_IMPORTED_MODULE_1__["default"].subtle.importKey('jwk', keyData, ...rest);
78993
+ }
78994
+ throw err;
78995
+ }
78370
78996
  };
78371
78997
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (parse);
78372
78998
 
@@ -78631,10 +79257,10 @@ function subtleDsa(alg, algorithm) {
78631
79257
  case 'ES384':
78632
79258
  case 'ES512':
78633
79259
  return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };
78634
- case (0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && 'EdDSA':
78635
- const { namedCurve } = algorithm;
78636
- return { name: namedCurve, namedCurve };
78637
79260
  case 'EdDSA':
79261
+ if ((0,_env_js__WEBPACK_IMPORTED_MODULE_0__.isCloudflareWorkers)() && algorithm.name === 'NODE-ED25519') {
79262
+ return { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' };
79263
+ }
78638
79264
  return { name: algorithm.name };
78639
79265
  default:
78640
79266
  throw new _util_errors_js__WEBPACK_IMPORTED_MODULE_1__.JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
@@ -79058,6 +79684,7 @@ class JWKSMultipleMatchingKeys extends JOSEError {
79058
79684
  return 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
79059
79685
  }
79060
79686
  }
79687
+ Symbol.asyncIterator;
79061
79688
  class JWKSTimeout extends JOSEError {
79062
79689
  constructor() {
79063
79690
  super(...arguments);