@ar.io/wayfinder-core 0.0.3-alpha.4 → 0.0.3-alpha.6
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/utils/hash.js +2 -2
- package/dist/wayfinder.js +3 -3
- package/package.json +1 -1
package/dist/utils/hash.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import
|
|
17
|
+
import * as crypto from 'crypto';
|
|
18
18
|
import { defaultLogger } from '../wayfinder.js';
|
|
19
19
|
import { toB64Url } from './base64.js';
|
|
20
20
|
export function isAsyncIterable(obj) {
|
|
@@ -48,7 +48,7 @@ export async function hashDataStreamToB64Url({ stream, algorithm = 'sha256', log
|
|
|
48
48
|
const asyncIterable = isAsyncIterable(stream)
|
|
49
49
|
? stream
|
|
50
50
|
: readableStreamToAsyncIterable(stream);
|
|
51
|
-
const hash = createHash(algorithm);
|
|
51
|
+
const hash = crypto.createHash(algorithm);
|
|
52
52
|
let bytesProcessed = 0;
|
|
53
53
|
for await (const chunk of asyncIterable) {
|
|
54
54
|
hash.update(chunk);
|
package/dist/wayfinder.js
CHANGED
|
@@ -187,7 +187,7 @@ export function sandboxFromId(id) {
|
|
|
187
187
|
*/
|
|
188
188
|
export const createWayfinderClient = ({ getGateways, resolveUrl, verifyData, selectGateway, emitter = new WayfinderEmitter(), logger = defaultLogger, strict = false, }) => {
|
|
189
189
|
return async (input, init) => {
|
|
190
|
-
if (!(input instanceof URL)) {
|
|
190
|
+
if (typeof input !== 'string' && !(input instanceof URL)) {
|
|
191
191
|
logger?.debug('URL is not a string, skipping routing', {
|
|
192
192
|
input,
|
|
193
193
|
});
|
|
@@ -207,8 +207,8 @@ export const createWayfinderClient = ({ getGateways, resolveUrl, verifyData, sel
|
|
|
207
207
|
// select the target gateway
|
|
208
208
|
const selectedGateway = await selectGateway({
|
|
209
209
|
gateways: await getGateways(),
|
|
210
|
-
path: input.pathname.split('/')[1],
|
|
211
|
-
subdomain: input.hostname.split('.')[0],
|
|
210
|
+
path: input instanceof URL ? input.pathname.split('/')[1] : '',
|
|
211
|
+
subdomain: input instanceof URL ? input.hostname.split('.')[0] : '',
|
|
212
212
|
});
|
|
213
213
|
logger?.debug('Selected gateway', {
|
|
214
214
|
originalUrl: url,
|
package/package.json
CHANGED