question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crypto API isn't detected on alternative platforms

See original GitHub issue

I run across this using Cloudflare Workers. It should be possible to use this library by instead checking for a crypto global instead of trying to detect `window. Documentation from Cloudflare here: https://developers.cloudflare.com/workers/reference/apis/web-crypto/.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
DavidJFelixcommented, Jun 1, 2022

Hey, if anyone else finds this issue like I did and is using cloudflare workers, here’s what worked for me:

import {monotonicFactory} from 'ulid'
// or import {factory} from 'ulid'

const prng = () => {
  const buffer = new Uint8Array(1)
  crypto.getRandomValues(buffer)
  return buffer[0] / 0xff
}
export const ulid = monotonicFactory(prng) // or factory(prng)

This will bypass the code that checks for browser crypto and allow you to set your own. The PRNG function is the same as used internally with a different global reference.

I think this package may be abandoned, I’m working on potentially forking it.

1reaction
SokichiFujitacommented, Dec 21, 2020

I also could not use ulid in Web Worker of Chrome or Safari by the same reason.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best cryptocurrency APIs of 2022 (full review) - Abstract API
1. Binance API. Binance trading API for marketpla. Binance is a free to use API that uses third-party platforms to allow users ...
Read more >
Crypto APIs blockchain infrastructure suite
Blockchain infrastructure suite for Web 3 - reduce development time and save costs.
Read more >
PSA Crypto API adoption on Zephyr · Issue #43712 - GitHub
This issue is not about whether Zephyr will use or provide the PSA crypto API. That is already the case. What we are...
Read more >
Top 5 Cryptocurrency APIs for Developers
In this article, we learn the top 5 best crypto APIs in 2020. Learn how to develop with Python for accurate cryptocurrency market...
Read more >
To the moon: defining and detecting cryptocurrency pump-and ...
The scientific literature on cryptocurrency pump-and-dump schemes is scarce, and government regulation has not yet caught up, leaving ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found