@superfunctions/oauth-testing 0.0.1
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.
- package/README.md +49 -0
- package/dist/browser-auth-fixtures.d.ts +19 -0
- package/dist/browser-auth-fixtures.d.ts.map +1 -0
- package/dist/browser-auth-fixtures.js +74 -0
- package/dist/browser-auth-fixtures.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @superfunctions/oauth-testing
|
|
2
|
+
|
|
3
|
+
Deterministic OAuth testing helpers built on the shared in-memory storage contracts.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @superfunctions/oauth-testing vitest
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {
|
|
15
|
+
InMemoryOAuthStateStore,
|
|
16
|
+
InMemoryTokenVault,
|
|
17
|
+
createMockOAuthProviderDescriptor,
|
|
18
|
+
} from "@superfunctions/oauth-testing";
|
|
19
|
+
|
|
20
|
+
const provider = createMockOAuthProviderDescriptor({
|
|
21
|
+
id: "mock-github",
|
|
22
|
+
defaultScopes: ["read:user"],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const stateStore = new InMemoryOAuthStateStore();
|
|
26
|
+
const tokenVault = new InMemoryTokenVault();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Package Boundary
|
|
30
|
+
|
|
31
|
+
`@superfunctions/oauth-testing` owns test fixtures only:
|
|
32
|
+
|
|
33
|
+
- `createMockOAuthProviderDescriptor()`
|
|
34
|
+
- in-memory fixture aliases from `@superfunctions/oauth-storage`
|
|
35
|
+
- browser-auth schema/composition fixtures
|
|
36
|
+
|
|
37
|
+
It is not a production runtime package and should not be used as your durable OAuth storage layer.
|
|
38
|
+
|
|
39
|
+
## Production Notes
|
|
40
|
+
|
|
41
|
+
- Use this package only in tests or local harnesses.
|
|
42
|
+
- If you need production routing, use `@superfunctions/oauth-router`.
|
|
43
|
+
- If you need production token persistence, use `@superfunctions/oauth-storage` and prefer `EncryptedTokenVault`.
|
|
44
|
+
|
|
45
|
+
## Related Packages
|
|
46
|
+
|
|
47
|
+
- Shared storage: [../oauth-storage/README.md](../oauth-storage/README.md)
|
|
48
|
+
- Flow orchestration: [../oauth-flow/README.md](../oauth-flow/README.md)
|
|
49
|
+
- Route factories: [../oauth-router/README.md](../oauth-router/README.md)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OAuthTokenSet } from "@superfunctions/oauth-core";
|
|
2
|
+
import type { OAuthFlowCallbackInput, OAuthFlowStartInput } from "@superfunctions/oauth-flow";
|
|
3
|
+
export interface BrowserAuthFixture {
|
|
4
|
+
startInput: OAuthFlowStartInput;
|
|
5
|
+
callbackInput: OAuthFlowCallbackInput;
|
|
6
|
+
tokenSet: OAuthTokenSet;
|
|
7
|
+
eventSnapshot: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface AuthFnSchemaCompositionFixture {
|
|
10
|
+
config: {
|
|
11
|
+
namespace: string;
|
|
12
|
+
plugins: string[];
|
|
13
|
+
};
|
|
14
|
+
expectedTables: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare function createBrowserAuthFixture(): BrowserAuthFixture;
|
|
17
|
+
export declare function createAuthFnSchemaCompositionFixture(): AuthFnSchemaCompositionFixture;
|
|
18
|
+
export declare function redactSecrets<T>(value: T): T;
|
|
19
|
+
//# sourceMappingURL=browser-auth-fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-auth-fixtures.d.ts","sourceRoot":"","sources":["../src/browser-auth-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAE9F,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,mBAAmB,CAAC;IAChC,aAAa,EAAE,sBAAsB,CAAC;IACtC,QAAQ,EAAE,aAAa,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;IACF,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAID,wBAAgB,wBAAwB,IAAI,kBAAkB,CAuC7D;AAED,wBAAgB,oCAAoC,IAAI,8BAA8B,CAcrF;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAE5C"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const REDACTED = "[REDACTED]";
|
|
2
|
+
export function createBrowserAuthFixture() {
|
|
3
|
+
const tokenSet = {
|
|
4
|
+
accessToken: "access-secret-token",
|
|
5
|
+
refreshToken: "refresh-secret-token",
|
|
6
|
+
tokenType: "Bearer",
|
|
7
|
+
expiresAt: "2026-03-22T00:00:00.000Z",
|
|
8
|
+
idToken: "id-secret-token",
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
startInput: {
|
|
12
|
+
providerId: "google",
|
|
13
|
+
redirectUri: "https://app.example/callback",
|
|
14
|
+
subject: {
|
|
15
|
+
kind: "browser-auth",
|
|
16
|
+
intentId: "intent_browser_01",
|
|
17
|
+
returnTo: "https://app.example/post-auth",
|
|
18
|
+
},
|
|
19
|
+
requestId: "req_browser_01",
|
|
20
|
+
},
|
|
21
|
+
callbackInput: {
|
|
22
|
+
providerId: "google",
|
|
23
|
+
code: "oauth-code-01",
|
|
24
|
+
state: "st_browser_01",
|
|
25
|
+
redirectUri: "https://app.example/callback",
|
|
26
|
+
requestId: "req_browser_02",
|
|
27
|
+
},
|
|
28
|
+
tokenSet,
|
|
29
|
+
eventSnapshot: redactSecrets({
|
|
30
|
+
name: "oauth.flow.callback.success",
|
|
31
|
+
requestId: "req_browser_02",
|
|
32
|
+
details: {
|
|
33
|
+
accessToken: tokenSet.accessToken,
|
|
34
|
+
refreshToken: tokenSet.refreshToken,
|
|
35
|
+
idToken: tokenSet.idToken,
|
|
36
|
+
providerId: "google",
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function createAuthFnSchemaCompositionFixture() {
|
|
42
|
+
return {
|
|
43
|
+
config: {
|
|
44
|
+
namespace: "auth",
|
|
45
|
+
plugins: ["password", "emailOtp", "socialOAuth"],
|
|
46
|
+
},
|
|
47
|
+
expectedTables: [
|
|
48
|
+
"users",
|
|
49
|
+
"sessions",
|
|
50
|
+
"password_credentials",
|
|
51
|
+
"otp_challenges",
|
|
52
|
+
"oauth_accounts",
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function redactSecrets(value) {
|
|
57
|
+
return redactValue(value);
|
|
58
|
+
}
|
|
59
|
+
function redactValue(value) {
|
|
60
|
+
if (Array.isArray(value)) {
|
|
61
|
+
return value.map((entry) => redactValue(entry));
|
|
62
|
+
}
|
|
63
|
+
if (value && typeof value === "object") {
|
|
64
|
+
return Object.fromEntries(Object.entries(value).map(([key, entryValue]) => [
|
|
65
|
+
key,
|
|
66
|
+
shouldRedactKey(key) ? REDACTED : redactValue(entryValue),
|
|
67
|
+
]));
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
function shouldRedactKey(key) {
|
|
72
|
+
return /(token|secret|authorization|bearer|password)/i.test(key);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=browser-auth-fixtures.js.map
|
|
@@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AAgB;SACjB;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAI,KAAQ;IACvC,OAAO,WAAW,CAAC,KAAK,CAAM,CAAC;AACjC,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC;YAC1E,GAAG;YACH,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC;SAC1D,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,+CAA+C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OAuthProviderDescriptor } from "@superfunctions/oauth-core";
|
|
2
|
+
export { MemoryOAuthStateStore as InMemoryOAuthStateStore, MemoryTokenVault as InMemoryTokenVault } from "@superfunctions/oauth-storage";
|
|
3
|
+
export { createAuthFnSchemaCompositionFixture, createBrowserAuthFixture, redactSecrets, } from "./browser-auth-fixtures.js";
|
|
4
|
+
export declare function createMockOAuthProviderDescriptor(overrides?: Partial<OAuthProviderDescriptor>): OAuthProviderDescriptor;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EACL,qBAAqB,IAAI,uBAAuB,EAChD,gBAAgB,IAAI,kBAAkB,EACvC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,oCAAoC,EACpC,wBAAwB,EACxB,aAAa,GACd,MAAM,4BAA4B,CAAC;AAEpC,wBAAgB,iCAAiC,CAC/C,SAAS,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAC/C,uBAAuB,CAYzB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { MemoryOAuthStateStore as InMemoryOAuthStateStore, MemoryTokenVault as InMemoryTokenVault } from "@superfunctions/oauth-storage";
|
|
2
|
+
export { createAuthFnSchemaCompositionFixture, createBrowserAuthFixture, redactSecrets, } from "./browser-auth-fixtures.js";
|
|
3
|
+
export function createMockOAuthProviderDescriptor(overrides = {}) {
|
|
4
|
+
return {
|
|
5
|
+
id: "mock",
|
|
6
|
+
authorizationUrl: "https://mock.example/auth",
|
|
7
|
+
tokenUrl: "https://mock.example/token",
|
|
8
|
+
defaultScopes: ["read"],
|
|
9
|
+
supportsPkce: true,
|
|
10
|
+
supportsRefreshToken: true,
|
|
11
|
+
scopeSeparator: " ",
|
|
12
|
+
tokenAuthMethod: "client_secret_post",
|
|
13
|
+
...overrides
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,IAAI,uBAAuB,EAChD,gBAAgB,IAAI,kBAAkB,EACvC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,oCAAoC,EACpC,wBAAwB,EACxB,aAAa,GACd,MAAM,4BAA4B,CAAC;AAEpC,MAAM,UAAU,iCAAiC,CAC/C,YAA8C,EAAE;IAEhD,OAAO;QACL,EAAE,EAAE,MAAM;QACV,gBAAgB,EAAE,2BAA2B;QAC7C,QAAQ,EAAE,4BAA4B;QACtC,aAAa,EAAE,CAAC,MAAM,CAAC;QACvB,YAAY,EAAE,IAAI;QAClB,oBAAoB,EAAE,IAAI;QAC1B,cAAc,EAAE,GAAG;QACnB,eAAe,EAAE,oBAAoB;QACrC,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@superfunctions/oauth-testing",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "OAuth testing utilities for Superfunctions",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"test": "vitest --config ./vitest.config.ts --run",
|
|
20
|
+
"test:watch": "vitest --config ./vitest.config.ts --watch",
|
|
21
|
+
"lint": "echo 'lint not configured'",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"clean": "rm -rf dist"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"oauth",
|
|
27
|
+
"testing",
|
|
28
|
+
"superfunctions"
|
|
29
|
+
],
|
|
30
|
+
"author": "21n",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/21nCo/super-functions.git",
|
|
35
|
+
"directory": "packages/oauth-testing"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@superfunctions/oauth-core": "0.0.1",
|
|
42
|
+
"@superfunctions/oauth-flow": "0.0.1",
|
|
43
|
+
"@superfunctions/oauth-storage": "0.0.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^22.0.0",
|
|
47
|
+
"typescript": "^5.6.0",
|
|
48
|
+
"vitest": "^3.2.4"
|
|
49
|
+
}
|
|
50
|
+
}
|