NobGit
public imalexnord read

Slot

Calendar-first scheduling powered by Cloudflare Workers and Google Calendar.

Languages

Repository composition by tracked source files.

TypeScript
TypeScript 79% CSS 19% SQL 2% HTML 0%
Create file Wiki Documentation
Clone
https://nobgit.com/user/imalexnord/slot.git
ssh://[email protected]:2222/user/imalexnord/slot.git

Trace

worker/crypto.ts

Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.

crypto.ts on main
Author Date Commit Line Code
Alex Nord 3 days ago 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
1
import type { Env } from './types';
Open commit View diff
1 import type { Env } from './types';
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
2
Open commit View diff
2
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
3
const encoder = new TextEncoder();
Open commit View diff
3 const encoder = new TextEncoder();
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
4
const decoder = new TextDecoder();
Open commit View diff
4 const decoder = new TextDecoder();
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
5
Open commit View diff
5
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
6
function toArrayBuffer(bytes: Uint8Array): ArrayBuffer {
Open commit View diff
6 function toArrayBuffer(bytes: Uint8Array): ArrayBuffer {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
7
  return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer;
Open commit View diff
7 return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
8
}
Open commit View diff
8 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
9
Open commit View diff
9
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
10
function base64Url(bytes: Uint8Array): string {
Open commit View diff
10 function base64Url(bytes: Uint8Array): string {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
11
  let binary = '';
Open commit View diff
11 let binary = '';
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
12
  for (const byte of bytes) binary += String.fromCharCode(byte);
Open commit View diff
12 for (const byte of bytes) binary += String.fromCharCode(byte);
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
13
  return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
Open commit View diff
13 return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
14
}
Open commit View diff
14 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
15
Open commit View diff
15
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
16
function fromBase64(value: string): Uint8Array {
Open commit View diff
16 function fromBase64(value: string): Uint8Array {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
17
  const normalized = value.replace(/-/g, '+').replace(/_/g, '/');
Open commit View diff
17 const normalized = value.replace(/-/g, '+').replace(/_/g, '/');
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
18
  const padded = normalized.padEnd(Math.ceil(normalized.length / 4) * 4, '=');
Open commit View diff
18 const padded = normalized.padEnd(Math.ceil(normalized.length / 4) * 4, '=');
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
19
  const binary = atob(padded);
Open commit View diff
19 const binary = atob(padded);
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
20
  return Uint8Array.from(binary, (char) => char.charCodeAt(0));
Open commit View diff
20 return Uint8Array.from(binary, (char) => char.charCodeAt(0));
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
21
}
Open commit View diff
21 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
22
Open commit View diff
22
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
23
async function hmacKey(secret: string): Promise<CryptoKey> {
Open commit View diff
23 async function hmacKey(secret: string): Promise<CryptoKey> {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
24
  return crypto.subtle.importKey(
Open commit View diff
24 return crypto.subtle.importKey(
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
25
    'raw',
Open commit View diff
25 'raw',
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
26
    encoder.encode(secret),
Open commit View diff
26 encoder.encode(secret),
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
27
    { name: 'HMAC', hash: 'SHA-256' },
Open commit View diff
27 { name: 'HMAC', hash: 'SHA-256' },
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
28
    false,
Open commit View diff
28 false,
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
29
    ['sign', 'verify'],
Open commit View diff
29 ['sign', 'verify'],
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
30
  );
Open commit View diff
30 );
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
31
}
Open commit View diff
31 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
32
Open commit View diff
32
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
33
export async function signSession(env: Env, email: string): Promise<string> {
Open commit View diff
33 export async function signSession(env: Env, email: string): Promise<string> {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
34
  const payload = base64Url(encoder.encode(JSON.stringify({ email, exp: Date.now() + 7 * 86400_000 })));
Open commit View diff
34 const payload = base64Url(encoder.encode(JSON.stringify({ email, exp: Date.now() + 7 * 86400_000 })));
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
35
  const signature = new Uint8Array(
Open commit View diff
35 const signature = new Uint8Array(
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
36
    await crypto.subtle.sign('HMAC', await hmacKey(env.SESSION_SECRET), encoder.encode(payload)),
Open commit View diff
36 await crypto.subtle.sign('HMAC', await hmacKey(env.SESSION_SECRET), encoder.encode(payload)),
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
37
  );
Open commit View diff
37 );
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
38
  return `${payload}.${base64Url(signature)}`;
Open commit View diff
38 return `${payload}.${base64Url(signature)}`;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
39
}
Open commit View diff
39 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
40
Open commit View diff
40
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
41
export async function verifySession(env: Env, token: string | null): Promise<string | null> {
Open commit View diff
41 export async function verifySession(env: Env, token: string | null): Promise<string | null> {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
42
  if (!token) return null;
Open commit View diff
42 if (!token) return null;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
43
  const [payload, signature] = token.split('.');
Open commit View diff
43 const [payload, signature] = token.split('.');
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
44
  if (!payload || !signature) return null;
Open commit View diff
44 if (!payload || !signature) return null;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
45
  const ok = await crypto.subtle.verify(
Open commit View diff
45 const ok = await crypto.subtle.verify(
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
46
    'HMAC',
Open commit View diff
46 'HMAC',
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
47
    await hmacKey(env.SESSION_SECRET),
Open commit View diff
47 await hmacKey(env.SESSION_SECRET),
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
48
    toArrayBuffer(fromBase64(signature)),
Open commit View diff
48 toArrayBuffer(fromBase64(signature)),
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
49
    encoder.encode(payload),
Open commit View diff
49 encoder.encode(payload),
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
50
  );
Open commit View diff
50 );
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
51
  if (!ok) return null;
Open commit View diff
51 if (!ok) return null;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
52
Open commit View diff
52
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
53
  try {
Open commit View diff
53 try {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
54
    const parsed = JSON.parse(decoder.decode(fromBase64(payload))) as { email?: string; exp?: number };
Open commit View diff
54 const parsed = JSON.parse(decoder.decode(fromBase64(payload))) as { email?: string; exp?: number };
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
55
    if (!parsed.email || !parsed.exp || parsed.exp < Date.now()) return null;
Open commit View diff
55 if (!parsed.email || !parsed.exp || parsed.exp < Date.now()) return null;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
56
    return parsed.email;
Open commit View diff
56 return parsed.email;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
57
  } catch {
Open commit View diff
57 } catch {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
58
    return null;
Open commit View diff
58 return null;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
59
  }
Open commit View diff
59 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
60
}
Open commit View diff
60 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
61
Open commit View diff
61
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
62
async function encryptionKey(env: Env): Promise<CryptoKey> {
Open commit View diff
62 async function encryptionKey(env: Env): Promise<CryptoKey> {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
63
  const raw = fromBase64(env.TOKEN_ENCRYPTION_KEY);
Open commit View diff
63 const raw = fromBase64(env.TOKEN_ENCRYPTION_KEY);
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
64
  if (raw.byteLength !== 32) throw new Error('TOKEN_ENCRYPTION_KEY must decode to 32 bytes');
Open commit View diff
64 if (raw.byteLength !== 32) throw new Error('TOKEN_ENCRYPTION_KEY must decode to 32 bytes');
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
65
  return crypto.subtle.importKey('raw', toArrayBuffer(raw), { name: 'AES-GCM' }, false, ['encrypt', 'decrypt']);
Open commit View diff
65 return crypto.subtle.importKey('raw', toArrayBuffer(raw), { name: 'AES-GCM' }, false, ['encrypt', 'decrypt']);
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
66
}
Open commit View diff
66 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
67
Open commit View diff
67
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
68
export async function encryptToken(env: Env, value: string): Promise<string> {
Open commit View diff
68 export async function encryptToken(env: Env, value: string): Promise<string> {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
69
  const iv = crypto.getRandomValues(new Uint8Array(12));
Open commit View diff
69 const iv = crypto.getRandomValues(new Uint8Array(12));
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
70
  const ciphertext = new Uint8Array(
Open commit View diff
70 const ciphertext = new Uint8Array(
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
71
    await crypto.subtle.encrypt({ name: 'AES-GCM', iv: toArrayBuffer(iv) }, await encryptionKey(env), encoder.encode(value)),
Open commit View diff
71 await crypto.subtle.encrypt({ name: 'AES-GCM', iv: toArrayBuffer(iv) }, await encryptionKey(env), encoder.encode(value)),
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
72
  );
Open commit View diff
72 );
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
73
  return `${base64Url(iv)}.${base64Url(ciphertext)}`;
Open commit View diff
73 return `${base64Url(iv)}.${base64Url(ciphertext)}`;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
74
}
Open commit View diff
74 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
75
Open commit View diff
75
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
76
export async function decryptToken(env: Env, value: string): Promise<string> {
Open commit View diff
76 export async function decryptToken(env: Env, value: string): Promise<string> {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
77
  const [ivText, ciphertextText] = value.split('.');
Open commit View diff
77 const [ivText, ciphertextText] = value.split('.');
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
78
  if (!ivText || !ciphertextText) throw new Error('Invalid encrypted token');
Open commit View diff
78 if (!ivText || !ciphertextText) throw new Error('Invalid encrypted token');
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
79
  const plaintext = await crypto.subtle.decrypt(
Open commit View diff
79 const plaintext = await crypto.subtle.decrypt(
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
80
    { name: 'AES-GCM', iv: toArrayBuffer(fromBase64(ivText)) },
Open commit View diff
80 { name: 'AES-GCM', iv: toArrayBuffer(fromBase64(ivText)) },
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
81
    await encryptionKey(env),
Open commit View diff
81 await encryptionKey(env),
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
82
    toArrayBuffer(fromBase64(ciphertextText)),
Open commit View diff
82 toArrayBuffer(fromBase64(ciphertextText)),
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
83
  );
Open commit View diff
83 );
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
84
  return decoder.decode(plaintext);
Open commit View diff
84 return decoder.decode(plaintext);
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
85
}
Open commit View diff
85 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
86
Open commit View diff
86
Alex Nord 1 day ago 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
87
Open commit View diff
87
same change 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
88
export function randomUrlToken(bytes = 32): string {
Open commit View diff
88 export function randomUrlToken(bytes = 32): string {
same change 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
89
  return base64Url(crypto.getRandomValues(new Uint8Array(bytes)));
Open commit View diff
89 return base64Url(crypto.getRandomValues(new Uint8Array(bytes)));
same change 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
90
}
Open commit View diff
90 }
same change 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
91
Open commit View diff
91
same change 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
92
export async function sha256Base64Url(value: string): Promise<string> {
Open commit View diff
92 export async function sha256Base64Url(value: string): Promise<string> {
same change 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
93
  const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', encoder.encode(value)));
Open commit View diff
93 const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', encoder.encode(value)));
same change 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
94
  return base64Url(digest);
Open commit View diff
94 return base64Url(digest);
same change 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
95
}
Open commit View diff
95 }
same change 9aa588b

feat: add rescheduling, time proposals and Stripe cancellation refunds

Full commit hash
9aa588b368f7c46ba3d287199a3d95506867c927
Author
Alex Nord <[email protected]>
Date
1 day ago
Selected line
96
Open commit View diff
96
Alex Nord 3 days ago 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
97
export function getCookie(request: Request, key: string): string | null {
Open commit View diff
97 export function getCookie(request: Request, key: string): string | null {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
98
  const cookie = request.headers.get('Cookie') ?? '';
Open commit View diff
98 const cookie = request.headers.get('Cookie') ?? '';
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
99
  for (const part of cookie.split(';')) {
Open commit View diff
99 for (const part of cookie.split(';')) {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
100
    const [name, ...rest] = part.trim().split('=');
Open commit View diff
100 const [name, ...rest] = part.trim().split('=');
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
101
    if (name === key) return decodeURIComponent(rest.join('='));
Open commit View diff
101 if (name === key) return decodeURIComponent(rest.join('='));
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
102
  }
Open commit View diff
102 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
103
  return null;
Open commit View diff
103 return null;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
104
}
Open commit View diff
104 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
105
Open commit View diff
105
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
106
export function sessionCookie(value: string, maxAge = 7 * 86400, secure = true): string {
Open commit View diff
106 export function sessionCookie(value: string, maxAge = 7 * 86400, secure = true): string {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
107
  const securePart = secure ? '; Secure' : '';
Open commit View diff
107 const securePart = secure ? '; Secure' : '';
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
108
  return `meet_session=${encodeURIComponent(value)}; Path=/; HttpOnly${securePart}; SameSite=Lax; Max-Age=${maxAge}`;
Open commit View diff
108 return `meet_session=${encodeURIComponent(value)}; Path=/; HttpOnly${securePart}; SameSite=Lax; Max-Age=${maxAge}`;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
109
}
Open commit View diff
109 }
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
110
Open commit View diff
110
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
111
export function clearSessionCookie(secure = true): string {
Open commit View diff
111 export function clearSessionCookie(secure = true): string {
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
112
  const securePart = secure ? '; Secure' : '';
Open commit View diff
112 const securePart = secure ? '; Secure' : '';
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
113
  return `meet_session=; Path=/; HttpOnly${securePart}; SameSite=Lax; Max-Age=0`;
Open commit View diff
113 return `meet_session=; Path=/; HttpOnly${securePart}; SameSite=Lax; Max-Age=0`;
same change 45c38c3

Prepare Slot booking worker

Full commit hash
45c38c3ae5284118e8d65aa9d49e90850b1209f5
Author
Alex Nord <[email protected]>
Date
3 days ago
Selected line
114
}
Open commit View diff
114 }