-
Notifications
You must be signed in to change notification settings - Fork 1
feat(js-types-auth): Setup authentication types package #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # path to a directory with all packages | ||
| storage: ../tmp/local-registry/storage | ||
|
|
||
| # a list of other known repositories we can talk to | ||
| uplinks: | ||
| npmjs: | ||
| url: https://registry.npmjs.org/ | ||
| maxage: 60m | ||
|
|
||
| packages: | ||
| '**': | ||
| # give all users (including non-authenticated users) full access | ||
| # because it is a local registry | ||
| access: $all | ||
| publish: $all | ||
| unpublish: $all | ||
|
|
||
| # if package is not available locally, proxy requests to npm registry | ||
| proxy: npmjs | ||
|
|
||
| # log settings | ||
| log: | ||
| type: stdout | ||
| format: pretty | ||
| level: warn | ||
|
|
||
| publish: | ||
| allow_offline: true # set offline to true to allow publish offline |
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
apps/docs/src/app/categories/javascript/types/ng-doc.category.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { NgDocCategory } from '@ng-doc/core'; | ||
| import JavascriptCategory from '../ng-doc.category'; | ||
|
|
||
| const TypesCategory: NgDocCategory = { | ||
| title: 'Types', | ||
| category: JavascriptCategory, | ||
| }; | ||
|
|
||
| export default TypesCategory; |
33 changes: 33 additions & 0 deletions
33
apps/docs/src/app/pages/docs/javascript/types/authentication/index.md
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| keyword: AuthenticationPage | ||
| --- | ||
|
|
||
| `@studiohyperdrive/types` is a collection of individual packages that aim to form a bridge between front-end and back-end related packages. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```shell | ||
| npm install @studiohyperdrive/types-auth | ||
| ``` | ||
|
|
||
| ### Versioning and build information | ||
|
|
||
| This package will follow a semver-like format, `major.minor.patch`, in which: | ||
|
|
||
| - `major`: Follows the Angular major version | ||
| - `minor`: Introduces new features and (potential) breaking changes | ||
| - `patch`: Introduces bugfixes and minor non-breaking changes | ||
|
|
||
| For more information about the build process, authors, contributions and issues, we refer to the [ngx-tools](https://github.com/studiohyperdrive/hyperdrive-opensource) repository. | ||
|
|
||
| ## Types | ||
|
|
||
| In order to plug into the corresponding frontend packages, the package provides an `AuthenticatedUserSession` and an `AuthenticationResponse` type. | ||
|
|
||
| `AuthenticatedUserSession` provides the basics for both permissions and feature flags provided to a user during their session. | ||
|
|
||
| `AuthenticationResponse` provides the authenticated user, an optional session and optional metadata. | ||
|
|
||
| ## Corresponding packages | ||
|
|
||
| For Angular, the corresponding package is [@studiohyperdrive/ngx-auth](https://open-source.studiohyperdrive.be/docs/angular/authentication/introduction). |
11 changes: 11 additions & 0 deletions
11
apps/docs/src/app/pages/docs/javascript/types/authentication/ng-doc.page.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { NgDocPage } from '@ng-doc/core'; | ||
| import { TypesCategory } from '../../../../../categories/javascript'; | ||
|
|
||
| const AuthenticationPage: NgDocPage = { | ||
| title: `Authentication`, | ||
| mdFile: './index.md', | ||
| category: TypesCategory, | ||
| order: 1, | ||
| }; | ||
|
|
||
| export default AuthenticationPage; |
11 changes: 11 additions & 0 deletions
11
apps/docs/src/app/pages/docs/javascript/types/introduction/index.md
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| keyword: IntroductionPage | ||
| --- | ||
|
|
||
| `@studiohyperdrive/types` is a collection of individual packages that aim to form a bridge between frontend and backend related packages. | ||
|
|
||
| ## For developers | ||
|
|
||
| Our `@studiohyperdrive/types` packages form the bridge between backend and frontend applications, ensuring that both sides of the story can easily connect with each other. These packages are divided based on their context with the intent of keeping them as lightweight as possible. | ||
|
|
||
| Looking for more information on how these packages can help you out in your application? Check out the individual packages to find out more! |
11 changes: 11 additions & 0 deletions
11
apps/docs/src/app/pages/docs/javascript/types/introduction/ng-doc.page.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { NgDocPage } from '@ng-doc/core'; | ||
| import { TypesCategory } from '../../../../../categories/javascript'; | ||
|
|
||
| const IntroductionPage: NgDocPage = { | ||
| title: `Introduction`, | ||
| mdFile: './index.md', | ||
| category: TypesCategory, | ||
| order: 0, | ||
| }; | ||
|
|
||
| export default IntroductionPage; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "extends": ["../../../../.eslintrc.json"], | ||
| "ignorePatterns": ["!**/*"], | ||
| "overrides": [ | ||
| { | ||
| "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
| "rules": {} | ||
| }, | ||
| { | ||
| "files": ["*.ts", "*.tsx"], | ||
| "rules": {} | ||
| }, | ||
| { | ||
| "files": ["*.js", "*.jsx"], | ||
| "rules": {} | ||
| }, | ||
| { | ||
| "files": ["*.json"], | ||
| "parser": "jsonc-eslint-parser", | ||
| "rules": { | ||
| "@nx/dependency-checks": "error" | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Javascript Tools: Authentication Types (`@studiohyperdrive/types-auth`) | ||
|
|
||
| `@studiohyperdrive/types-auth` is a set of base types used for the frontend-equivalent packages such as `@studiohyperdrive/ngx-auth`. | ||
|
|
||
| ## Installation | ||
|
|
||
| Install the package first: | ||
|
|
||
| ```shell | ||
| npm install @studiohyperdrive/types-auth | ||
| ``` | ||
|
|
||
| ## Versioning and build information | ||
|
|
||
| This package will follow a semver-like format, `major.minor.patch`, in which: | ||
|
|
||
| - `major`: Introduces new features or breaking changes | ||
| - `minor`: Introduces minor non-breaking changes | ||
| - `patch`: Introduces bugfixes | ||
|
|
||
| For more information about the build process, authors, contributions and issues, we refer to the [hyperdrive-opensource](https://github.com/studiohyperdrive/hyperdrive-opensource) repository. | ||
|
|
||
| ## Documentation | ||
|
|
||
| To find more information regarding this package, we refer to [our documentation platform](https://open-source.studiohyperdrive.be/docs/javascript/types/introduction). |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "name": "@studiohyperdrive/types-auth", | ||
| "version": "0.0.1", | ||
| "dependencies": {}, | ||
| "type": "commonjs", | ||
| "main": "./index.cjs", | ||
| "typings": "./index.d.ts", | ||
| "description": "A package containing common authentication related types", | ||
| "keywords": [ | ||
| "authentication", | ||
| "user", | ||
| "session", | ||
| "features", | ||
| "permissions" | ||
| ], | ||
| "homepage": "https://open-source.studiohyperdrive.be/docs/javascript/types/introduction", | ||
| "author": { | ||
| "name": "Studio Hyperdrive", | ||
| "url": "https://studiohyperdrive.be/" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/studiohyperdrive/hyperdrive-opensource", | ||
| "directory": "libs/javascript/types/auth/src" | ||
| }, | ||
| "license": "MIT" | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "name": "js-types-auth", | ||
| "$schema": "../../../../node_modules/nx/schemas/project-schema.json", | ||
| "sourceRoot": "libs/javascript/types/auth/src", | ||
| "projectType": "library", | ||
| "release": { | ||
| "version": { | ||
| "generatorOptions": { | ||
| "packageRoot": "dist/{projectRoot}", | ||
| "currentVersionResolver": "git-tag" | ||
| } | ||
| } | ||
| }, | ||
| "tags": [], | ||
| "targets": { | ||
| "build": { | ||
| "executor": "@nx/esbuild:esbuild", | ||
| "outputs": ["{options.outputPath}"], | ||
| "options": { | ||
| "outputPath": "dist/libs/javascript/types/auth", | ||
| "main": "libs/javascript/types/auth/src/index.ts", | ||
| "tsConfig": "libs/javascript/types/auth/tsconfig.lib.json", | ||
| "format": ["cjs"], | ||
| "assets": ["libs/javascript/types/auth/*.md"], | ||
| "generatePackageJson": true | ||
| } | ||
| }, | ||
| "nx-release-publish": { | ||
| "options": { | ||
| "packageRoot": "dist/{projectRoot}" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './lib'; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './types'; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './user.types'; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * A base type for the session of the authenticated user, providing features and permissions | ||
| * | ||
| * @template FeatureType - A list of possible features | ||
| * @template PermissionType - A list of possible permissions | ||
| */ | ||
| export interface AuthenticatedUserSession< | ||
| FeatureType extends string = string, | ||
| PermissionType extends string = string, | ||
| > { | ||
| /** | ||
| * An optional list of feature flags assigned to the user | ||
| */ | ||
| features?: FeatureType[]; | ||
|
|
||
| /** | ||
| * An optional list of permissions assigned to the user | ||
| */ | ||
| permissions?: PermissionType[]; | ||
| } | ||
|
|
||
| /** | ||
| * A base type for an authentication request, providing the authenticated user and optional session and metadata. | ||
| * | ||
| * @template UserType - The type of the authenticated user | ||
| * @template MetadataType - An optional type of the metadata | ||
| */ | ||
| export interface AuthenticationResponse<UserType, MetadataType = any> { | ||
| /** | ||
| * The authenticated user | ||
| */ | ||
| user: UserType; | ||
| /** | ||
| * An optional set of session related data | ||
| */ | ||
| session?: AuthenticatedUserSession; | ||
| /** | ||
| * The optional set of metadata | ||
| */ | ||
| metadata?: MetadataType; | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "extends": "../../../../tsconfig.base.json", | ||
| "compilerOptions": { | ||
| "module": "commonjs", | ||
| "strict": true, | ||
| "noImplicitOverride": true, | ||
| "noPropertyAccessFromIndexSignature": true | ||
| }, | ||
| "files": [], | ||
| "include": [], | ||
| "references": [ | ||
| { | ||
| "path": "./tsconfig.lib.json" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "extends": "./tsconfig.json", | ||
| "compilerOptions": { | ||
| "outDir": "../../../../dist/out-tsc", | ||
| "declaration": true, | ||
| "types": ["node"], | ||
| "composite": true | ||
| }, | ||
| "include": ["src/**/*.ts"] | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.