The error might occur because your development / local server is not using a secure origin. A secure origin is one that loads resources either from the local machine or from a server that has cryptographic authentication. The digest function is part of the Web Crypto API, which you can access through the window.crypto.subtle property. However, this property is only available in secure origins, such as https:// pages. This is according to the Chromium Projects page here and the spec, which states that crypto.subtle should be undefined in insecure contexts.
Some examples of secure origins are:
- (https, *, *)
- (wss, *, *)
- (*, localhost, *)
- (*, 127/8, *)
- (*, ::1/128, *)
- (file, *, —)
- (chrome-extension, *, —)
These patterns match the (scheme, host, port) of the origin. For example, https://example.com:443 is a secure origin because it matches the first pattern. However, http://example.com:80 (domain / virtual host) is not a secure origin because it does not use https.
Other supported secure origins are http://localhost and http://127.0.0.1, which match the third and fourth patterns respectively. These origins refer to the local machine and are considered trusted.