Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 50 additions & 50 deletions modules/auth/module.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
{
"name": "Authentication",
"description": "Authenticate users with multiple authentication methods.",
"icon": "key",
"tags": [
"core",
"auth",
"user"
],
"authors": [
"rivet-gg",
"NathanFlurry"
],
"status": "stable",
"dependencies": {
"email": {},
"users": {},
"rate_limit": {}
},
"scripts": {
"send_email_verification": {
"name": "Send Email Verification",
"description": "Send a one-time verification code to a user's email address to authenticate them.",
"public": true
},
"complete_email_verification": {
"name": "Complete Email Verification",
"description": "Verify a user's email address with a one-time verification code.",
"public": true
}
},
"errors": {
"provider_disabled": {
"name": "Provider Disabled"
},
"verification_code_invalid": {
"name": "Verification Code Invalid"
},
"verification_code_attempt_limit": {
"name": "Verification Code Attempt Limit"
},
"verification_code_expired": {
"name": "Verification Code Expired"
},
"verification_code_already_used": {
"name": "Verification Code Already Used"
},
"email_already_used": {
"name": "Email Already Used"
}
}
"name": "Authentication",
"description": "Authenticate users with multiple authentication methods.",
"icon": "key",
"tags": [
"core",
"auth",
"user"
],
"authors": [
"rivet-gg",
"NathanFlurry"
],
"status": "stable",
"dependencies": {
"email": {},
"users": {},
"rate_limit": {}
},
"scripts": {
"send_email_verification": {
"name": "Send Email Verification",
"description": "Send a one-time verification code to a user's email address to authenticate them.",
"public": true
},
"complete_email_verification": {
"name": "Complete Email Verification",
"description": "Verify a user's email address with a one-time verification code.",
"public": true
}
},
"errors": {
"provider_disabled": {
"name": "Provider Disabled"
},
"verification_code_invalid": {
"name": "Verification Code Invalid"
},
"verification_code_attempt_limit": {
"name": "Verification Code Attempt Limit"
},
"verification_code_expired": {
"name": "Verification Code Expired"
},
"verification_code_already_used": {
"name": "Verification Code Already Used"
},
"email_already_used": {
"name": "Email Already Used"
}
}
}
5 changes: 1 addition & 4 deletions modules/auth/scripts/complete_email_verification.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { assertExists } from "https://deno.land/std@0.208.0/assert/mod.ts";
import {
RuntimeError,
ScriptContext,
} from "../module.gen.ts";
import { RuntimeError, ScriptContext } from "../module.gen.ts";
import { TokenWithSecret } from "../../tokens/utils/types.ts";

export interface Request {
Expand Down
36 changes: 18 additions & 18 deletions modules/auth/tests/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test("e2e", async (ctx: TestContext) => {
const { user } = await ctx.modules.users.create({});

const { token: session } = await ctx.modules.users.createToken({
userId: user.id
userId: user.id,
});

const fakeEmail = faker.internet.email();
Expand All @@ -18,15 +18,16 @@ test("e2e", async (ctx: TestContext) => {
{
const authRes = await ctx.modules.auth.sendEmailVerification({
email: fakeEmail,
userToken: session.token
userToken: session.token,
});

// Look up correct code
const { code } = await ctx.db.emailPasswordlessVerification.findFirstOrThrow({
where: {
id: authRes.verification.id,
},
});
const { code } = await ctx.db.emailPasswordlessVerification
.findFirstOrThrow({
where: {
id: authRes.verification.id,
},
});

// Now by verifying the email, we register, and can also use
// this to verify the token
Expand All @@ -37,10 +38,9 @@ test("e2e", async (ctx: TestContext) => {

assertEquals(verifyRes.token.type, "user");


// Make sure we end up with the same user we started with
const verifyRes2 = await ctx.modules.users.authenticateToken({
userToken: verifyRes.token.token
userToken: verifyRes.token.token,
});

assertEquals(verifyRes2.userId, user.id);
Expand All @@ -50,26 +50,26 @@ test("e2e", async (ctx: TestContext) => {
// but without a token, expecting the same user
{
const authRes = await ctx.modules.auth.sendEmailVerification({
email: fakeEmail
email: fakeEmail,
});

// Look up correct code
const { code: code } = await ctx.db.emailPasswordlessVerification.findFirstOrThrow({
where: {
id: authRes.verification.id,
},
});
const { code: code } = await ctx.db.emailPasswordlessVerification
.findFirstOrThrow({
where: {
id: authRes.verification.id,
},
});

const verifyRes = await ctx.modules.auth.completeEmailVerification({
verificationId: authRes.verification.id,
code: code,
});

const verifyRes2 = await ctx.modules.users.authenticateToken({
userToken: verifyRes.token.token
userToken: verifyRes.token.token,
});

assertEquals(verifyRes2.userId, user.id);
assertEquals(verifyRes2.userId, user.id);
}
});

88 changes: 44 additions & 44 deletions modules/currency/module.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
{
"name": "Currency",
"description": "Track user balances and allow them to deposit and withdraw.",
"icon": "coin",
"tags": [
"economy"
],
"authors": [
"ABCxFF"
],
"status": "preview",
"dependencies": {
"rate_limit": {},
"users": {}
},
"scripts": {
"deposit": {
"name": "Deposit"
},
"withdraw": {
"name": "Withdraw"
},
"get_balance": {
"name": "Get Balance"
},
"set_balance": {
"name": "Set Balance"
},
"get_balance_by_token": {
"name": "Get Balance by Token",
"public": true
}
},
"errors": {
"invalid_user": {
"name": "Invalid User"
},
"invalid_amount": {
"name": "Invalid Amount"
},
"not_enough_funds": {
"name": "Not Enough Funds"
}
}
}
"name": "Currency",
"description": "Track user balances and allow them to deposit and withdraw.",
"icon": "coin",
"tags": [
"economy"
],
"authors": [
"ABCxFF"
],
"status": "preview",
"dependencies": {
"rate_limit": {},
"users": {}
},
"scripts": {
"deposit": {
"name": "Deposit"
},
"withdraw": {
"name": "Withdraw"
},
"get_balance": {
"name": "Get Balance"
},
"set_balance": {
"name": "Set Balance"
},
"get_balance_by_token": {
"name": "Get Balance by Token",
"public": true
}
},
"errors": {
"invalid_user": {
"name": "Invalid User"
},
"invalid_amount": {
"name": "Invalid Amount"
},
"not_enough_funds": {
"name": "Not Enough Funds"
}
}
}
52 changes: 26 additions & 26 deletions modules/email/module.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"name": "Email",
"description": "Send emails using multiple providers.",
"icon": "envelope",
"tags": [
"email"
],
"authors": [
"rivet-gg",
"NathanFlurry"
],
"status": "stable",
"scripts": {
"send_email": {
"name": "Send Email"
}
},
"errors": {
"email_missing_content": {
"name": "Email Missing Content",
"description": "Email must have `html` and/or `text`"
},
"sendgrid_error": {
"name": "SendGrid Error"
}
}
}
"name": "Email",
"description": "Send emails using multiple providers.",
"icon": "envelope",
"tags": [
"email"
],
"authors": [
"rivet-gg",
"NathanFlurry"
],
"status": "stable",
"scripts": {
"send_email": {
"name": "Send Email"
}
},
"errors": {
"email_missing_content": {
"name": "Email Missing Content",
"description": "Email must have `html` and/or `text`"
},
"sendgrid_error": {
"name": "SendGrid Error"
}
}
}
6 changes: 3 additions & 3 deletions modules/email/scripts/send_email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export async function run(
}

async function useSendGrid(config: ProviderSendGrid, req: Request) {
const apiKeyVariable = config.apiKeyVariable ?? "SENDGRID_API_KEY";
const apiKey = Deno.env.get(apiKeyVariable);
assertExists(apiKey, `Missing environment variable: ${apiKeyVariable}`);
const apiKeyVariable = config.apiKeyVariable ?? "SENDGRID_API_KEY";
const apiKey = Deno.env.get(apiKeyVariable);
assertExists(apiKey, `Missing environment variable: ${apiKeyVariable}`);

const content = [];
if (req.text) {
Expand Down
Loading