-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* export sha256sum and sha1sum functions * remove console.log (#2794) * feat: add helper for campaigns url * export sha256sum and sha1sum functions * feat: add helper for campaigns url * fix geo migrations * fix type for datasets --------- Co-authored-by: Ludovic Delhomme <[email protected]>
- Loading branch information
1 parent
17d635d
commit 2f92e8b
Showing
9 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
export async function getAiresLastUrl(url: string): Promise<string> { | ||
const response = await fetch(url, { method: "get" }); | ||
const res = await response.json(); | ||
const list = res | ||
? res.history.filter((h) => h.payload.schema_name !== null) | ||
: []; | ||
if (!response.ok) { | ||
console.error(res.error.data); | ||
} | ||
const list = res ? res.history.filter((h: any) => h.payload.schema_name !== null) : []; | ||
const fileUrl = list.length > 0 ? list[0].payload.permanent_url : ""; | ||
return fileUrl; | ||
} | ||
|
||
export async function getCampaignsLastUrl(url: string): Promise<string> { | ||
const response = await fetch(url, { method: "get" }); | ||
const res = await response.json(); | ||
if (!response.ok) { | ||
console.error(res.error.data); | ||
} | ||
const list = res ? res.resources : []; | ||
const fileUrl = list.length > 0 ? list[0].latest : ""; | ||
return fileUrl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,11 +232,12 @@ export { | |
}; | ||
export * as semver from "jsr:@std/semver@1"; | ||
export * as collections from "jsr:@std/collections@1"; | ||
export * as stdCrypto from "https://deno.land/[email protected]/crypto/mod.ts"; | ||
export * as stdCrypto from "jsr:@std/crypto@1"; | ||
export { | ||
decodeBase64, | ||
encodeBase64, | ||
} from "https://deno.land/[email protected]/encoding/base64.ts"; | ||
encodeHex, | ||
} from "jsr:@std/encoding@1"; | ||
export * as log from "https://deno.land/[email protected]/log/mod.ts"; | ||
export * as path from "https://deno.land/[email protected]/path/posix/mod.ts"; | ||
export * as bcrypt from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { bcrypt, decodeBase64, encodeBase64, stdCrypto } from "@/deps.ts"; | ||
import { bcrypt, decodeBase64, encodeBase64, encodeHex, stdCrypto } from "@/deps.ts"; | ||
import { exists, read } from "@/lib/file/index.ts"; | ||
import { encodeHex } from "https://deno.land/[email protected]/encoding/hex.ts"; | ||
|
||
export async function bcrypt_hash( | ||
plaintext: string, | ||
|
@@ -72,6 +71,17 @@ export async function createHash(message: string): Promise<string> { | |
} | ||
|
||
export async function sha256sum(source: string | ReadableStream<Uint8Array>): Promise<string> { | ||
return shaSum(source, "SHA-256"); | ||
} | ||
|
||
export async function sha1sum(source: string | ReadableStream<Uint8Array>): Promise<string> { | ||
return shaSum(source, "SHA-1"); | ||
} | ||
|
||
export async function shaSum( | ||
source: string | ReadableStream<Uint8Array>, | ||
alg: stdCrypto.DigestAlgorithm = "SHA-256", | ||
): Promise<string> { | ||
let stream; | ||
if (source instanceof ReadableStream) { | ||
stream = source; | ||
|
@@ -84,6 +94,6 @@ export async function sha256sum(source: string | ReadableStream<Uint8Array>): Pr | |
stream = file.readable; | ||
} | ||
|
||
const hashBuffer = await stdCrypto.crypto.subtle.digest("SHA-256", stream); | ||
const hashBuffer = await stdCrypto.crypto.subtle.digest(alg, stream); | ||
return encodeHex(hashBuffer); | ||
} |