Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
8fc6287
Create invite-guest.yml
simonbs Nov 2, 2023
99e6c16
Update invite-guest.yml
simonbs Nov 2, 2023
41c8bdb
Update invite-guest.yml
simonbs Nov 2, 2023
d21cc4b
Update invite-guest.yml
simonbs Nov 2, 2023
bee8d38
Update invite-guest.yml
simonbs Nov 2, 2023
76e4d1d
Update invite-guest.yml
simonbs Nov 2, 2023
7af4ebe
Update invite-guest.yml
simonbs Nov 2, 2023
b46389e
Update invite-guest.yml
simonbs Nov 2, 2023
b956f71
Update invite-guest.yml
simonbs Nov 2, 2023
38f4921
Update invite-guest.yml
simonbs Nov 2, 2023
198a29c
Adds invite-user action
simonbs Nov 2, 2023
599ea26
Merge branch 'develop' of github.com:shapehq/shape-docs into develop
simonbs Nov 2, 2023
c449786
Uses invite-user action
simonbs Nov 2, 2023
0e7a714
Update invite-guest.yml
simonbs Nov 2, 2023
ec49d1c
Updates action description
simonbs Nov 2, 2023
7da3aa3
Update invite-guest.yml
simonbs Nov 2, 2023
e8ffa6d
Merge branch 'develop' of github.com:shapehq/shape-docs into develop
simonbs Nov 2, 2023
64557ff
Uses Node 20
simonbs Nov 2, 2023
a74f014
Update invite-guest.yml
simonbs Nov 2, 2023
166b868
Update invite-guest.yml
simonbs Nov 2, 2023
e2864e7
Fixes invitation not sent
simonbs Nov 2, 2023
20719a1
Merge branch 'develop' of github.com:shapehq/shape-docs into develop
simonbs Nov 2, 2023
8eff108
Logs name instead of user ID
simonbs Nov 2, 2023
4c77fae
Bump tailwindcss from 3.3.3 to 3.3.5
dependabot[bot] Nov 6, 2023
1e23457
Bump core-js from 3.33.1 to 3.33.2
dependabot[bot] Nov 6, 2023
db508a5
Bump @typescript-eslint/parser from 6.9.0 to 6.9.1
dependabot[bot] Nov 6, 2023
0b08e1e
Bump npm from 10.2.1 to 10.2.3
dependabot[bot] Nov 6, 2023
e83341f
Moves errors to common
simonbs Nov 6, 2023
a477eda
Extends GitHubClient to get org membership status
simonbs Nov 6, 2023
2681ef7
Throws InvalidSessionError when fetching projects with invalid session
simonbs Nov 6, 2023
ff014c3
Shows invalid session page when catching InvalidSessionError
simonbs Nov 6, 2023
1ab92ea
Adds session validation to composition
simonbs Nov 6, 2023
3e23c87
Removes debug logs
simonbs Nov 6, 2023
b635f77
Fixes linting error
simonbs Nov 6, 2023
aaeba6c
Fixes unit tests
simonbs Nov 6, 2023
4f8794a
Improves error message
simonbs Nov 6, 2023
f64e6de
Fixes linting warning
simonbs Nov 6, 2023
dd44294
Adds tests for GitHubOrganizationSessionValidator
simonbs Nov 6, 2023
0c1436d
Adds tests for SessionValidatingProjectDataSource
simonbs Nov 6, 2023
fa84596
Removes OrganizationMembershipStatus type
simonbs Nov 6, 2023
0a67598
Merge pull request #119 from shapehq/dependabot/npm_and_yarn/tailwind…
simonbs Nov 6, 2023
793635a
Merge pull request #123 from shapehq/dependabot/npm_and_yarn/npm-10.2.3
simonbs Nov 6, 2023
23fc3a5
Merge pull request #120 from shapehq/dependabot/npm_and_yarn/core-js-…
simonbs Nov 6, 2023
7cb40bc
Merge pull request #121 from shapehq/dependabot/npm_and_yarn/typescri…
simonbs Nov 6, 2023
758863b
Bump auth0 from 4.0.2 to 4.1.0
dependabot[bot] Nov 6, 2023
fc37b39
Merge pull request #122 from shapehq/dependabot/npm_and_yarn/auth0-4.1.0
simonbs Nov 6, 2023
5d7bab6
Merge branch 'develop' into enhancement/validate-github-organization
simonbs Nov 6, 2023
b7f54fe
Renames InitialOAuthTokenService to OAuthTokenTransferer
simonbs Nov 6, 2023
4c10477
Removes debug logging
simonbs Nov 6, 2023
1abd29d
Removes unused parameter
simonbs Nov 6, 2023
3e8cf0a
Merge pull request #124 from shapehq/enhancement/validate-github-orga…
simonbs Nov 6, 2023
5b16936
Simplifies project interface
simonbs Nov 7, 2023
401fcf6
Introduces new ILogOutHandler concept
simonbs Nov 7, 2023
f678ab6
Simplifies project interface
simonbs Nov 7, 2023
6214ea2
Merge pull request #125 from shapehq/enhancement/project-interface
simonbs Nov 7, 2023
c27e6d0
Introduces new ILogOutHandler concept
simonbs Nov 7, 2023
bc3a5f1
Fixes compile errors after merge
simonbs Nov 7, 2023
d2eba88
Merge branch 'develop' into enhancement/log-out-handler
simonbs Nov 7, 2023
1869205
Merge pull request #126 from shapehq/enhancement/log-out-handler
simonbs Nov 7, 2023
bb9061b
Merge branch 'develop' into enhancement/guest-login
simonbs Nov 7, 2023
ba49088
Adds IAccessTokenService
simonbs Nov 7, 2023
91d97f4
Ignores unused variables starting with underscore
simonbs Nov 7, 2023
b7dc59c
Adds AccessTokenService
simonbs Nov 7, 2023
1008896
Removes unused code
simonbs Nov 7, 2023
f6fe1c7
Removes debug logging
simonbs Nov 7, 2023
4652757
Merge pull request #127 from shapehq/enhancement/access-token-service
simonbs Nov 7, 2023
6e4e3a6
Transfers credentials through ILogInHandler
simonbs Nov 7, 2023
3de56b2
Merge branch 'develop' into enhancement/login-transfer-credentials
simonbs Nov 7, 2023
dd712d1
Merge pull request #128 from shapehq/enhancement/login-transfer-crede…
simonbs Nov 7, 2023
5f23c8b
Fixes webhooks attempting to authenticate
simonbs Nov 7, 2023
833a378
Merge pull request #129 from shapehq/bugfix/authenticating-webhooks
simonbs Nov 7, 2023
1b9246e
Merge branch 'main' into develop
simonbs Nov 7, 2023
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
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"no-unmodified-loop-condition": ["error"],
"no-unreachable-loop": ["error"],
"no-unused-private-class-members": ["error"],
"require-atomic-updates": ["error"]
"require-atomic-updates": ["error"],
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
},
"parser": "@typescript-eslint/parser",
"plugins": [
Expand Down
15 changes: 15 additions & 0 deletions .github/actions/invite-user/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Invites User
description: Invites a user to Shape Docs.
inputs:
name:
description: The name of the user.
required: true
email:
description: The e-mail of the user to invite.
required: true
roles:
description: Comma-separated list of roles to assign to the user.
required: true
runs:
using: node20
main: dist/index.js
16 changes: 16 additions & 0 deletions .github/actions/invite-user/dist/index.js

Large diffs are not rendered by default.

217 changes: 217 additions & 0 deletions .github/actions/invite-user/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .github/actions/invite-user/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "invite-user",
"version": "1.0.0",
"description": "Invite a user to Shape Docs",
"main": "lib/index.js",
"author": "Shape",
"scripts": {
"build": "tsc && ncc build --minify",
"test": "jest"
},
"dependencies": {
"@actions/core": "^1.10.0",
"@vercel/ncc": "^0.34.0",
"auth0": "^4.1.0",
"axios": "^1.6.0"
},
"devDependencies": {
"typescript": "^5.2.2"
}
}
87 changes: 87 additions & 0 deletions .github/actions/invite-user/src/Action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import IStateStore from "./StateStore/IStateStore"
import ILogger from "./Logger/ILogger"
import IUserClient from "./UserClient/IUserClient"
import IPasswordGenerator from "./PasswordGenerator/IPasswordGenerator"
import IRoleNameParser from "./RoleNameParser/IRoleNameParser"

export interface ActionOptions {
readonly name: string
readonly email: string
readonly roles: string
}

export interface ActionConfig {
readonly stateStore: IStateStore
readonly logger: ILogger
readonly userClient: IUserClient
readonly passwordGenerator: IPasswordGenerator
readonly roleNameParser: IRoleNameParser
}

export default class Action {
private readonly stateStore: IStateStore
private readonly logger: ILogger
private readonly userClient: IUserClient
private readonly passwordGenerator: IPasswordGenerator
private readonly roleNameParser: IRoleNameParser

constructor(config: ActionConfig) {
this.stateStore = config.stateStore
this.logger = config.logger
this.userClient = config.userClient
this.passwordGenerator = config.passwordGenerator
this.roleNameParser = config.roleNameParser
}

async run(options: ActionOptions) {
if (!this.stateStore.isPost) {
await this.runMain(options)
this.stateStore.isPost = true
}
}

private async runMain(options: ActionOptions) {
if (!options.name || options.name.length == 0) {
throw new Error("No name supplied.")
}
if (!options.email || options.email.length == 0) {
throw new Error("No e-mail supplied.")
}
if (!options.roles || options.roles.length == 0) {
throw new Error("No roles supplied.")
}
const roleNames = this.roleNameParser.parse(options.roles)
if (roleNames.length == 0) {
throw new Error("No roles supplied.")
}
const existingUser = await this.userClient.getUser({ email: options.email })
let user = existingUser
if (!existingUser) {
const password = this.passwordGenerator.generatePassword()
const newUser = await this.userClient.createUser({
name: options.name,
email: options.email,
password: password
})
user = newUser
}
if (!user) {
throw new Error("Could not get an existing user or create a new user.")
}
const roles = await this.userClient.createRoles({ roleNames })
if (roles.length == 0) {
throw new Error("Received an empty set of roles.")
}
const roleIDs = roles.map(e => e.id)
await this.userClient.assignRolesToUser({
userID: user.id,
roleIDs: roleIDs
})
if (!existingUser) {
await this.userClient.sendChangePasswordEmail({ email: user.email })
this.logger.log(`${options.name} (${user.email}) has been invited.`)
} else {
this.logger.log(`${options.name} (${user.email}) has been updated.`)
}
}
}
4 changes: 4 additions & 0 deletions .github/actions/invite-user/src/Logger/ILogger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default interface ILogger {
log(message: string): void
error(message: string): void
}
12 changes: 12 additions & 0 deletions .github/actions/invite-user/src/Logger/Logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as core from "@actions/core"
import ILogger from "./ILogger"

export default class Logger implements ILogger {
log(message: string) {
console.log(message)
}

error(message: string) {
core.setFailed(message)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default interface IPasswordGenerator {
generatePassword(): string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import IPasswordGenerator from "./IPasswordGenerator"

export default class PasswordGenerator implements IPasswordGenerator {
generatePassword(): string {
let pass = ""
const str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#$"
const length = 18
for (let i = 1; i <= length; i++) {
const char = Math.floor(Math.random() * str.length + 1)
pass += str.charAt(char)
}
return pass
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default interface IRoleNameParser {
parse(roleNames: string): string[]
}
Loading