@pod-os/core 0.2.1-5680137.0 → 0.2.1-da0e5dd.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -25075,6 +25075,23 @@ var BrowserSession = class {
25075
25075
  }
25076
25076
  };
25077
25077
 
25078
+ // src/files/FileFetcher.ts
25079
+ var FileFetcher = class {
25080
+ constructor(session) {
25081
+ this.session = session;
25082
+ }
25083
+ fetchBlob(url) {
25084
+ return __async(this, null, function* () {
25085
+ return this.session.authenticatedFetch(url).then((response) => {
25086
+ if (!response.ok) {
25087
+ throw new Error(`${response.status} - ${response.statusText}`);
25088
+ }
25089
+ return response.blob();
25090
+ });
25091
+ });
25092
+ }
25093
+ };
25094
+
25078
25095
  // ../node_modules/@babel/runtime/helpers/esm/createClass.js
25079
25096
  function _defineProperties(target, props) {
25080
25097
  for (var i = 0; i < props.length; i++) {
@@ -37715,6 +37732,7 @@ var PodOS = class {
37715
37732
  constructor() {
37716
37733
  this.session = new BrowserSession();
37717
37734
  this.store = new Store(this.session);
37735
+ this.fileFetcher = new FileFetcher(this.session);
37718
37736
  }
37719
37737
  handleIncomingRedirect() {
37720
37738
  this.session.handleIncomingRedirect();
@@ -37722,6 +37740,9 @@ var PodOS = class {
37722
37740
  fetch(uri) {
37723
37741
  return this.store.fetch(uri);
37724
37742
  }
37743
+ fetchBlob(url) {
37744
+ return this.fileFetcher.fetchBlob(url);
37745
+ }
37725
37746
  trackSession(callback) {
37726
37747
  return this.session.trackSession(callback);
37727
37748
  }
package/lib/index.js CHANGED
@@ -25043,6 +25043,21 @@ ${newlined}
25043
25043
  }
25044
25044
  };
25045
25045
 
25046
+ // src/files/FileFetcher.ts
25047
+ var FileFetcher = class {
25048
+ constructor(session) {
25049
+ this.session = session;
25050
+ }
25051
+ async fetchBlob(url) {
25052
+ return this.session.authenticatedFetch(url).then((response) => {
25053
+ if (!response.ok) {
25054
+ throw new Error(`${response.status} - ${response.statusText}`);
25055
+ }
25056
+ return response.blob();
25057
+ });
25058
+ }
25059
+ };
25060
+
25046
25061
  // ../node_modules/@babel/runtime/helpers/esm/createClass.js
25047
25062
  function _defineProperties(target, props) {
25048
25063
  for (var i = 0; i < props.length; i++) {
@@ -37686,9 +37701,11 @@ ${newlined}
37686
37701
  var PodOS = class {
37687
37702
  session;
37688
37703
  store;
37704
+ fileFetcher;
37689
37705
  constructor() {
37690
37706
  this.session = new BrowserSession();
37691
37707
  this.store = new Store(this.session);
37708
+ this.fileFetcher = new FileFetcher(this.session);
37692
37709
  }
37693
37710
  handleIncomingRedirect() {
37694
37711
  this.session.handleIncomingRedirect();
@@ -37696,6 +37713,9 @@ ${newlined}
37696
37713
  fetch(uri) {
37697
37714
  return this.store.fetch(uri);
37698
37715
  }
37716
+ fetchBlob(url) {
37717
+ return this.fileFetcher.fetchBlob(url);
37718
+ }
37699
37719
  trackSession(callback) {
37700
37720
  return this.session.trackSession(callback);
37701
37721
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pod-os/core",
3
- "version": "0.2.1-5680137.0",
3
+ "version": "0.2.1-da0e5dd.0",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./types/index.d.ts",
@@ -27,11 +27,13 @@
27
27
  "@babel/preset-env": "^7.18.10",
28
28
  "@babel/preset-typescript": "^7.18.6",
29
29
  "@types/jest": "^29.0.0",
30
+ "@types/jest-when": "^3.5.2",
30
31
  "@typescript-eslint/eslint-plugin": "^5.36.1",
31
32
  "@typescript-eslint/parser": "^5.36.1",
32
33
  "esbuild": "^0.15.6",
33
34
  "eslint": "^8.23.0",
34
35
  "jest": "^29.0.1",
36
+ "jest-when": "^3.5.1",
35
37
  "prettier": "^2.7.1",
36
38
  "rimraf": "^3.0.2",
37
39
  "typescript": "^4.8.2"
package/types/Store.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Fetcher, IndexedFormula } from "rdflib";
2
- import { BrowserSession } from "./authentication";
2
+ import { PodOsSession } from "./authentication";
3
3
  import { Thing } from "./thing";
4
4
  export declare class Store {
5
5
  fetcher: Fetcher;
6
6
  graph: IndexedFormula;
7
- constructor(session: BrowserSession);
7
+ constructor(session: PodOsSession);
8
8
  fetch(uri: string): Promise<Response>;
9
9
  get(uri: string): Thing;
10
10
  }
@@ -1,5 +1,9 @@
1
1
  import { ISessionInfo } from "@inrupt/solid-client-authn-browser";
2
- export declare class BrowserSession {
2
+ export declare type AuthenticatedFetch = (url: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
3
+ export interface PodOsSession {
4
+ authenticatedFetch: AuthenticatedFetch;
5
+ }
6
+ export declare class BrowserSession implements PodOsSession {
3
7
  private readonly session;
4
8
  private readonly _authenticatedFetch;
5
9
  get authenticatedFetch(): (url: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
@@ -0,0 +1,6 @@
1
+ import { PodOsSession } from "../authentication";
2
+ export declare class FileFetcher {
3
+ private session;
4
+ constructor(session: PodOsSession);
5
+ fetchBlob(url: string): Promise<Blob>;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
package/types/index.d.ts CHANGED
@@ -4,9 +4,11 @@ export * from "./authentication";
4
4
  export declare class PodOS {
5
5
  private readonly session;
6
6
  readonly store: Store;
7
+ private fileFetcher;
7
8
  constructor();
8
9
  handleIncomingRedirect(): void;
9
10
  fetch(uri: string): Promise<Response>;
11
+ fetchBlob(url: string): Promise<Blob>;
10
12
  trackSession(callback: (session: ISessionInfo) => unknown): void;
11
13
  logout(): Promise<void>;
12
14
  login(oidcIssuer?: string): Promise<void>;