Skip to content

Commit

Permalink
Latest build
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-ignatov committed Aug 27, 2024
1 parent fe70afe commit 23b443d
Show file tree
Hide file tree
Showing 18 changed files with 11,676 additions and 10,779 deletions.
11 changes: 6 additions & 5 deletions dist/build/bundle.dev.html

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions dist/build/bundle.prod.html

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions dist/build/bundle.pure.dev.html

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions dist/build/bundle.pure.prod.html

Large diffs are not rendered by default.

22,279 changes: 11,578 additions & 10,701 deletions dist/build/fhir-client.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/build/fhir-client.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/build/fhir-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/build/fhir-client.min.js.map

Large diffs are not rendered by default.

66 changes: 37 additions & 29 deletions dist/build/fhir-client.pure.js

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

2 changes: 1 addition & 1 deletion dist/build/fhir-client.pure.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/build/fhir-client.pure.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/build/fhir-client.pure.min.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export = smart;

type storageFactory = (options?: fhirclient.JsonObject) => fhirclient.Storage;

// tslint:disable-next-line: no-namespace
declare namespace smart {
export const oauth2: fhirclient.SMART;
export function client(stateOrURI: fhirclient.ClientState | string): Client;
Expand Down
29 changes: 16 additions & 13 deletions dist/lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,22 @@ async function contextualize(requestOptions, client) {
* @param refId
* @param cache A map to store the resolved refs
* @param client The client instance
* @param [signal] The `AbortSignal` if any
* @param requestOptions Only signal and headers are currently used if provided
* @returns The resolved reference
* @private
*/
function getRef(refId, cache, client, signal) {
function getRef(refId, cache, client, requestOptions) {
if (!cache[refId]) {
const {
signal,
headers
} = requestOptions;
// Note that we set cache[refId] immediately! When the promise is
// settled it will be updated. This is to avoid a ref being fetched
// twice because some of these requests are executed in parallel.
cache[refId] = client.request({
url: refId,
headers,
signal
}).then(res => {
cache[refId] = res;
Expand All @@ -70,14 +75,14 @@ function getRef(refId, cache, client, signal) {
* Resolves a reference in the given resource.
* @param obj FHIR Resource
*/
function resolveRef(obj, path, graph, cache, client, signal) {
function resolveRef(obj, path, graph, cache, client, requestOptions) {
const node = (0, lib_1.getPath)(obj, path);
if (node) {
const isArray = Array.isArray(node);
return Promise.all((0, lib_1.makeArray)(node).filter(Boolean).map((item, i) => {
const ref = item.reference;
if (ref) {
return getRef(ref, cache, client, signal).then(sub => {
return getRef(ref, cache, client, requestOptions).then(sub => {
if (graph) {
if (isArray) {
if (path.indexOf("..") > -1) {
Expand Down Expand Up @@ -107,7 +112,7 @@ function resolveRef(obj, path, graph, cache, client, signal) {
* @param client The client instance
* @private
*/
function resolveRefs(obj, fhirOptions, cache, client, signal) {
function resolveRefs(obj, fhirOptions, cache, client, requestOptions) {
// 1. Sanitize paths, remove any invalid ones
let paths = (0, lib_1.makeArray)(fhirOptions.resolveReferences).filter(Boolean) // No false, 0, null, undefined or ""
.map(path => String(path).trim()).filter(Boolean); // No space-only strings
Expand Down Expand Up @@ -140,7 +145,7 @@ function resolveRefs(obj, fhirOptions, cache, client, signal) {
Object.keys(groups).sort().forEach(len => {
const group = groups[len];
task = task.then(() => Promise.all(group.map(path => {
return resolveRef(obj, path, !!fhirOptions.graph, cache, client, signal);
return resolveRef(obj, path, !!fhirOptions.graph, cache, client, requestOptions);
})));
});
return task;
Expand Down Expand Up @@ -607,7 +612,7 @@ class Client {
throw error;
}).then(data => {
// At this point we don't know what `data` actually is!
// We might gen an empty or falsy result. If so return it as is
// We might get an empty or falsy result. If so return it as is
// Also handle raw responses
if (!data || typeof data == "string" || data instanceof Response) {
if (requestOptions.includeResponse) {
Expand All @@ -616,16 +621,14 @@ class Client {
response
};
}

return data;
} // Resolve References ------------------------------------------


}
// Resolve References ------------------------------------------
return (async _data => {
if (_data.resourceType == "Bundle") {
await Promise.all((_data.entry || []).map(item => resolveRefs(item.resource, options, _resolvedRefs, this, signal)));
await Promise.all((_data.entry || []).map(item => resolveRefs(item.resource, options, _resolvedRefs, this, requestOptions)));
} else {
await resolveRefs(_data, options, _resolvedRefs, this, signal);
await resolveRefs(_data, options, _resolvedRefs, this, requestOptions);
}
return _data;
})(data)
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/adapters/NodeAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class NodeAdapter {
let host = req.headers.host;
if (req.headers["x-forwarded-host"]) {
host = req.headers["x-forwarded-host"];
if (req.headers["x-forwarded-port"]) {
if (req.headers["x-forwarded-port"] && host.indexOf(":") === -1) {
host += ":" + req.headers["x-forwarded-port"];
}
}
Expand Down
17 changes: 12 additions & 5 deletions dist/lib/security/browser.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
"use strict";

require("core-js/modules/es.typed-array.set.js");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.signCompactJws = exports.importJWK = exports.generatePKCEChallenge = exports.digestSha256 = exports.randomBytes = void 0;
const js_base64_1 = require("js-base64");
const crypto = typeof globalThis === "object" && globalThis.crypto ? globalThis.crypto : require("isomorphic-webcrypto").default;
const subtle = crypto.subtle;
const subtle = () => {
if (!crypto.subtle) {
if (!globalThis.isSecureContext) {
throw new Error("Some of the required subtle crypto functionality is not " + "available unless you run this app in secure context (using " + "HTTPS or running locally). See " + "https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts");
}
throw new Error("Some of the required subtle crypto functionality is not " + "available in the current environment (no crypto.subtle)");
}
return crypto.subtle;
};
const ALGS = {
ES384: {
name: "ECDSA",
Expand All @@ -28,7 +35,7 @@ function randomBytes(count) {
exports.randomBytes = randomBytes;
async function digestSha256(payload) {
const prepared = new TextEncoder().encode(payload);
const hash = await subtle.digest('SHA-256', prepared);
const hash = await subtle().digest('SHA-256', prepared);
return new Uint8Array(hash);
}
exports.digestSha256 = digestSha256;
Expand Down Expand Up @@ -59,7 +66,7 @@ async function importJWK(jwk) {
throw new Error('The "key_ops" property of the JWK does not contain "sign"');
}
try {
return await subtle.importKey("jwk", jwk, ALGS[jwk.alg], jwk.ext === true, jwk.key_ops // || ['sign']
return await subtle().importKey("jwk", jwk, ALGS[jwk.alg], jwk.ext === true, jwk.key_ops // || ['sign']
);
} catch (e) {
throw new Error(`The ${jwk.alg} is not supported by this browser: ${e}`);
Expand All @@ -72,7 +79,7 @@ async function signCompactJws(alg, privateKey, header, payload) {
}));
const jwtPayload = JSON.stringify(payload);
const jwtAuthenticatedContent = `${(0, js_base64_1.encodeURL)(jwtHeader)}.${(0, js_base64_1.encodeURL)(jwtPayload)}`;
const signature = await subtle.sign(Object.assign(Object.assign({}, privateKey.algorithm), {
const signature = await subtle().sign(Object.assign(Object.assign({}, privateKey.algorithm), {
hash: 'SHA-384'
}), privateKey, new TextEncoder().encode(jwtAuthenticatedContent));
return `${jwtAuthenticatedContent}.${(0, js_base64_1.fromUint8Array)(new Uint8Array(signature), true)}`;
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/smart.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ function shouldIncludeChallenge(S256supported, pkceMode) {
}
if (pkceMode === "required") {
if (!S256supported) {
throw new Error("Required PKCE code challenge method (`S256`) was not found.");
throw new Error("Required PKCE code challenge method (`S256`) was not found in the server's codeChallengeMethods declaration.");
}
return true;
}
Expand Down
3 changes: 1 addition & 2 deletions dist/lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Client from "./Client";
import { getPath, byCodes, byCode } from "./lib";
import { IncomingMessage } from "http";

// tslint:disable-next-line: no-namespace
declare namespace fhirclient {

interface RequestWithSession extends IncomingMessage {
Expand Down Expand Up @@ -339,7 +338,7 @@ declare namespace fhirclient {
/**
* Supported PKCE Code challenge methods
*/
codeChallengeMethods: string[];
codeChallengeMethods: string[];
}

/**
Expand Down

0 comments on commit 23b443d

Please sign in to comment.