Skip to content

Commit

Permalink
Change ulid to ulidx lib to support non-secure contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Polleps committed Jun 24, 2024
1 parent bd1017b commit 1c3b2bb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions browser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This changelog covers all five packages, as they are (for now) updated as a whol
- Added `resource.setVersion()` method.
- Added `collection.getMembersOnPage()` method.
- Added `collection.totalPages`.
- Fix lib not working in non-secure browser contexts.
- BREAKING CHANGE: Renamed `resource.getCommitsCollection` to `resource.getCommitsCollectionSubject`.
- BREAKING CHANGE: `resource.getChildrenCollection()` now returns a `Promise<Collection>` instead of a subject.
- BREAKING CHANGE: `resource.createSubject()` no longer accepts a class name as an argument and defaults to a fully random subject.
Expand Down
6 changes: 4 additions & 2 deletions browser/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"base64-arraybuffer": "^1.0.2",
"cross-fetch": "^3.1.4",
"fast-json-stable-stringify": "^2.1.0",
"ulid": "^2.3.0"
"ulidx": "^2.3.0"
},
"description": "",
"devDependencies": {
Expand All @@ -20,7 +20,9 @@
"vitest": "^0.34.6",
"whatwg-fetch": "^3.6.2"
},
"files": ["dist"],
"files": [
"dist"
],
"gitHead": "2172c73d8df4e5f273e6386676abc91b6c5b2707",
"license": "MIT",
"main": "dist/index.js",
Expand Down
11 changes: 10 additions & 1 deletion browser/lib/src/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,16 @@ export class Resource<C extends OptionalClass = any> {

if (validate) {
const fullProp = await this.store.getProperty(prop);
validateDatatype(value, fullProp.datatype);

try {
validateDatatype(value, fullProp.datatype);
} catch (e) {
if (e instanceof Error) {
e.message = `Error validating ${fullProp.shortname} with value ${value} for ${this.subject}: ${e.message}`;
}

throw e;
}
}

if (value === undefined) {
Expand Down
4 changes: 1 addition & 3 deletions browser/lib/src/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ulid } from 'ulid';

import { ulid } from 'ulidx';
import type { Agent } from './agent.js';
import {
removeCookieAuthentication,
Expand Down Expand Up @@ -148,7 +147,6 @@ export class Store {
this.client.setFetch(fetchOverride);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public addResources(
resources: Resource | Resource[],
opts?: AddResourcesOpts,
Expand Down
17 changes: 15 additions & 2 deletions browser/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c3b2bb

Please sign in to comment.