@boxyhq/saml-jackson 0.2.3-beta.207 → 0.2.3-beta.219

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.eslintrc.js +13 -0
  2. package/package.json +3 -3
  3. package/prettier.config.js +4 -0
  4. package/src/controller/api.ts +226 -0
  5. package/src/controller/error.ts +13 -0
  6. package/src/controller/oauth/allowed.ts +22 -0
  7. package/src/controller/oauth/code-verifier.ts +11 -0
  8. package/src/controller/oauth/redirect.ts +12 -0
  9. package/src/controller/oauth.ts +333 -0
  10. package/src/controller/utils.ts +17 -0
  11. package/src/db/db.ts +100 -0
  12. package/src/db/encrypter.ts +38 -0
  13. package/src/db/mem.ts +128 -0
  14. package/src/db/mongo.ts +110 -0
  15. package/src/db/redis.ts +103 -0
  16. package/src/db/sql/entity/JacksonIndex.ts +44 -0
  17. package/src/db/sql/entity/JacksonStore.ts +43 -0
  18. package/src/db/sql/entity/JacksonTTL.ts +17 -0
  19. package/src/db/sql/model/JacksonIndex.ts +3 -0
  20. package/src/db/sql/model/JacksonStore.ts +8 -0
  21. package/src/db/sql/sql.ts +184 -0
  22. package/src/db/store.ts +49 -0
  23. package/src/db/utils.ts +26 -0
  24. package/src/env.ts +42 -0
  25. package/src/index.ts +79 -0
  26. package/src/jackson.ts +171 -0
  27. package/src/read-config.ts +29 -0
  28. package/src/saml/claims.js +40 -0
  29. package/src/saml/saml.ts +234 -0
  30. package/src/saml/x509.js +48 -0
  31. package/src/test/api.test.ts.disabled +271 -0
  32. package/src/test/data/metadata/boxyhq.js +6 -0
  33. package/src/test/data/metadata/boxyhq.xml +30 -0
  34. package/src/test/data/saml_response +1 -0
  35. package/src/test/db.test.ts +318 -0
  36. package/src/test/oauth.test.ts.disabled +353 -0
  37. package/src/typings.ts +167 -0
  38. package/tsconfig.build.json +6 -0
  39. package/tsconfig.json +26 -0
  40. package/.nyc_output/522d751d-0cf8-42cc-9e6b-7c4f2c2ab0d4.json +0 -1
  41. package/.nyc_output/93c45454-d3b6-48a7-9885-209592dc290a.json +0 -1
  42. package/.nyc_output/da9b997e-732d-4bf2-a4e8-4b0568635c06.json +0 -1
  43. package/.nyc_output/processinfo/522d751d-0cf8-42cc-9e6b-7c4f2c2ab0d4.json +0 -1
  44. package/.nyc_output/processinfo/93c45454-d3b6-48a7-9885-209592dc290a.json +0 -1
  45. package/.nyc_output/processinfo/da9b997e-732d-4bf2-a4e8-4b0568635c06.json +0 -1
  46. package/.nyc_output/processinfo/index.json +0 -1
package/src/typings.ts ADDED
@@ -0,0 +1,167 @@
1
+ declare module 'saml-jackson' {
2
+ export type IdPConfig = {
3
+ defaultRedirectUrl: string;
4
+ redirectUrl: string;
5
+ tenant: string;
6
+ product: string;
7
+ rawMetadata: string;
8
+ };
9
+
10
+ export interface OAuth {
11
+ client_id: string;
12
+ client_secret: string;
13
+ provider: string;
14
+ }
15
+
16
+ export interface ISAMLConfig {
17
+ // Ensure backward compatibility
18
+ config(body: IdPConfig): Promise<OAuth>;
19
+
20
+ getConfig(body: {
21
+ clientID: string;
22
+ tenant: string;
23
+ product: string;
24
+ }): Promise<Partial<OAuth>>;
25
+
26
+ deleteConfig(body: {
27
+ clientID: string;
28
+ clientSecret: string;
29
+ tenant: string;
30
+ product: string;
31
+ }): Promise<void>;
32
+
33
+ // New methods
34
+ create(body: IdPConfig): Promise<OAuth>;
35
+
36
+ get(body: {
37
+ clientID: string;
38
+ tenant: string;
39
+ product: string;
40
+ }): Promise<Partial<OAuth>>;
41
+
42
+ delete(body: {
43
+ clientID: string;
44
+ clientSecret: string;
45
+ tenant: string;
46
+ product: string;
47
+ }): Promise<void>;
48
+ }
49
+
50
+ export interface IOAuthController {
51
+ authorize(body: OAuthReqBody): Promise<{ redirect_url: string }>;
52
+ samlResponse(body: SAMLResponsePayload): Promise<{ redirect_url: string }>;
53
+ token(body: OAuthTokenReq): Promise<OAuthTokenRes>;
54
+ userInfo(body: string): Promise<Profile>;
55
+ }
56
+
57
+ export interface OAuthReqBody {
58
+ response_type: 'code';
59
+ client_id: string;
60
+ redirect_uri: string;
61
+ state: string;
62
+ tenant: string;
63
+ product: string;
64
+ code_challenge: string;
65
+ code_challenge_method: 'plain' | 'S256' | '';
66
+ provider: 'saml';
67
+ }
68
+
69
+ export interface SAMLResponsePayload {
70
+ SAMLResponse: string;
71
+ RelayState: string;
72
+ }
73
+
74
+ export interface OAuthTokenReq {
75
+ client_id: string;
76
+ client_secret: string;
77
+ code_verifier: string;
78
+ code: string;
79
+ grant_type: 'authorization_code';
80
+ }
81
+
82
+ export interface OAuthTokenRes {
83
+ access_token: string;
84
+ token_type: 'bearer';
85
+ expires_in: number;
86
+ }
87
+
88
+ export interface Profile {
89
+ id: string;
90
+ email: string;
91
+ firstName: string;
92
+ lastName: string;
93
+ }
94
+
95
+ export interface Index {
96
+ name: string;
97
+ value: string;
98
+ }
99
+
100
+ export interface DatabaseDriver {
101
+ get(namespace: string, key: string): Promise<any>;
102
+ put(
103
+ namespace: string,
104
+ key: string,
105
+ val: any,
106
+ ttl: number,
107
+ indexes: Index[]
108
+ ): Promise<any>;
109
+ delete(namespace: string, key: string): Promise<any>;
110
+ getByIndex(namespace: string, idx: Index): Promise<any>;
111
+ }
112
+
113
+ export interface Storable {
114
+ get(key: string): Promise<any>;
115
+ put(key: string, val: any, ...indexes: Index[]): Promise<any>;
116
+ delete(key: string): Promise<any>;
117
+ getByIndex(idx: Index): Promise<any>;
118
+ }
119
+
120
+ export interface Encrypted {
121
+ iv: string;
122
+ tag: string;
123
+ value: string;
124
+ }
125
+
126
+ export type EncryptionKey = any;
127
+
128
+ export type DatabaseEngine = 'redis' | 'sql' | 'mongo' | 'mem';
129
+
130
+ export type DatabaseType = 'postgres' | 'cockroachdb' | 'mysql' | 'mariadb';
131
+
132
+ export interface DatabaseOption {
133
+ engine: DatabaseEngine;
134
+ url: string;
135
+ type: DatabaseType;
136
+ ttl: number;
137
+ cleanupLimit: number;
138
+ encryptionKey: string;
139
+ }
140
+
141
+ export interface SAMLReq {
142
+ ssoUrl?: string;
143
+ entityID: string;
144
+ callbackUrl: string;
145
+ isPassive?: boolean;
146
+ forceAuthn?: boolean;
147
+ identifierFormat?: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress';
148
+ providerName?: 'BoxyHQ';
149
+ signingKey: string;
150
+ }
151
+
152
+ export interface SAMLProfile {
153
+ audience: string;
154
+ claims: Record<string, any>;
155
+ issuer: string;
156
+ sessionIndex: string;
157
+ }
158
+
159
+ export interface JacksonOption {
160
+ externalUrl: string;
161
+ samlPath: string;
162
+ samlAudience?: string;
163
+ preLoadedConfig?: string;
164
+ idpEnabled?: boolean;
165
+ db: DatabaseOption;
166
+ }
167
+ }
@@ -0,0 +1,6 @@
1
+
2
+ {
3
+ "extends": "./tsconfig.json",
4
+ "exclude": ["node_modules", "**/test/*"],
5
+ }
6
+
package/tsconfig.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./dist",
4
+ "allowJs": true,
5
+ "module": "CommonJS",
6
+ "target": "es6", //same as es2015
7
+ "forceConsistentCasingInFileNames": true,
8
+ "noImplicitAny": false,
9
+ "strict": true,
10
+ "noImplicitThis": false,
11
+ "resolveJsonModule": true,
12
+ "esModuleInterop": true,
13
+ "declaration": true,
14
+ "noEmitOnError": false,
15
+ "noUnusedParameters": true,
16
+ "removeComments": false,
17
+ "strictNullChecks": true,
18
+ "allowSyntheticDefaultImports": true,
19
+ "experimentalDecorators": true
20
+ },
21
+ "include": ["./src/**/*"],
22
+ "exclude": ["node_modules"],
23
+ "ts-node": {
24
+ "files": true
25
+ }
26
+ }
@@ -1 +0,0 @@
1
- {"parent":"93c45454-d3b6-48a7-9885-209592dc290a","pid":3596,"argv":["/opt/hostedtoolcache/node/16.13.1/x64/bin/node","/home/runner/work/jackson/jackson/src/test/api.test.ts"],"execArgv":["-r","/home/runner/work/jackson/jackson/node_modules/ts-node/register/index.js"],"cwd":"/home/runner/work/jackson/jackson","time":1640694328676,"ppid":3579,"coverageFilename":"/home/runner/work/jackson/jackson/.nyc_output/522d751d-0cf8-42cc-9e6b-7c4f2c2ab0d4.json","externalId":"src/test/api.test.ts","uuid":"522d751d-0cf8-42cc-9e6b-7c4f2c2ab0d4","files":[]}
@@ -1 +0,0 @@
1
- {"parent":null,"pid":3579,"argv":["/opt/hostedtoolcache/node/16.13.1/x64/bin/node","/home/runner/work/jackson/jackson/node_modules/.bin/tap","--ts","--timeout=100","src/test/api.test.ts","src/test/oauth.test.ts"],"execArgv":[],"cwd":"/home/runner/work/jackson/jackson","time":1640694328360,"ppid":3568,"coverageFilename":"/home/runner/work/jackson/jackson/.nyc_output/93c45454-d3b6-48a7-9885-209592dc290a.json","externalId":"","uuid":"93c45454-d3b6-48a7-9885-209592dc290a","files":[]}
@@ -1 +0,0 @@
1
- {"parent":"93c45454-d3b6-48a7-9885-209592dc290a","pid":3590,"argv":["/opt/hostedtoolcache/node/16.13.1/x64/bin/node","/home/runner/work/jackson/jackson/src/test/oauth.test.ts"],"execArgv":["-r","/home/runner/work/jackson/jackson/node_modules/ts-node/register/index.js"],"cwd":"/home/runner/work/jackson/jackson","time":1640694328650,"ppid":3579,"coverageFilename":"/home/runner/work/jackson/jackson/.nyc_output/da9b997e-732d-4bf2-a4e8-4b0568635c06.json","externalId":"src/test/oauth.test.ts","uuid":"da9b997e-732d-4bf2-a4e8-4b0568635c06","files":[]}
@@ -1 +0,0 @@
1
- {"processes":{"522d751d-0cf8-42cc-9e6b-7c4f2c2ab0d4":{"parent":"93c45454-d3b6-48a7-9885-209592dc290a","externalId":"src/test/api.test.ts","children":[]},"93c45454-d3b6-48a7-9885-209592dc290a":{"parent":null,"children":["522d751d-0cf8-42cc-9e6b-7c4f2c2ab0d4","da9b997e-732d-4bf2-a4e8-4b0568635c06"]},"da9b997e-732d-4bf2-a4e8-4b0568635c06":{"parent":"93c45454-d3b6-48a7-9885-209592dc290a","externalId":"src/test/oauth.test.ts","children":[]}},"files":{},"externalIds":{"src/test/api.test.ts":{"root":"522d751d-0cf8-42cc-9e6b-7c4f2c2ab0d4","children":[]},"src/test/oauth.test.ts":{"root":"da9b997e-732d-4bf2-a4e8-4b0568635c06","children":[]}}}