@reactionary/fake 0.12.4 → 0.12.6
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.
|
@@ -9,6 +9,13 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
9
|
return result;
|
|
10
10
|
};
|
|
11
11
|
import {
|
|
12
|
+
ExternalLoginRedirectSchema,
|
|
13
|
+
IdentityMutationCompleteExternalLoginSchema,
|
|
14
|
+
IdentityMutationStartExternalLoginSchema,
|
|
15
|
+
IdentityProviderSchema,
|
|
16
|
+
IdentityQueryProvidersSchema,
|
|
17
|
+
PASSWORD_IDENTITY_PROVIDER,
|
|
18
|
+
error,
|
|
12
19
|
IdentityMutationLoginSchema,
|
|
13
20
|
IdentityMutationLogoutSchema,
|
|
14
21
|
IdentityMutationRegisterSchema,
|
|
@@ -58,6 +65,39 @@ class FakeIdentityCapability extends IdentityCapability {
|
|
|
58
65
|
register(_payload) {
|
|
59
66
|
throw new Error("Method not implemented.");
|
|
60
67
|
}
|
|
68
|
+
async listProviders(_payload) {
|
|
69
|
+
return success([
|
|
70
|
+
PASSWORD_IDENTITY_PROVIDER,
|
|
71
|
+
IdentityProviderSchema.parse({
|
|
72
|
+
identifier: { key: "fake-oidc" },
|
|
73
|
+
displayName: "Fake OIDC",
|
|
74
|
+
flow: "redirect"
|
|
75
|
+
})
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
async startExternalLogin(payload) {
|
|
79
|
+
const state = new Faker({ locale: [en, base] }).string.alphanumeric(32);
|
|
80
|
+
this.setPendingExternalLogin(payload.provider.key, state);
|
|
81
|
+
const location = new URL(payload.callbackUrl);
|
|
82
|
+
location.searchParams.set("code", "fake-code");
|
|
83
|
+
location.searchParams.set("state", state);
|
|
84
|
+
return success({ location: location.toString() });
|
|
85
|
+
}
|
|
86
|
+
async completeExternalLogin(payload) {
|
|
87
|
+
if (!this.consumePendingExternalLogin(payload.provider.key, payload.callbackParameters["state"])) {
|
|
88
|
+
return error({ type: "InvalidInput", error: "The login was not started in this session, or has expired" });
|
|
89
|
+
}
|
|
90
|
+
if (payload.callbackParameters["code"] === "conflict") {
|
|
91
|
+
return error({ type: "IdentityConflict", message: "An account with this email already exists" });
|
|
92
|
+
}
|
|
93
|
+
this.currentIdentity = {
|
|
94
|
+
type: "Registered",
|
|
95
|
+
id: { userId: `external-${payload.provider.key}` }
|
|
96
|
+
};
|
|
97
|
+
const identity = this.factory.parseIdentity(this.context, this.currentIdentity);
|
|
98
|
+
this.updateIdentityContext(identity);
|
|
99
|
+
return success(identity);
|
|
100
|
+
}
|
|
61
101
|
}
|
|
62
102
|
__decorateClass([
|
|
63
103
|
Reactionary({
|
|
@@ -83,6 +123,24 @@ __decorateClass([
|
|
|
83
123
|
outputSchema: IdentitySchema
|
|
84
124
|
})
|
|
85
125
|
], FakeIdentityCapability.prototype, "register", 1);
|
|
126
|
+
__decorateClass([
|
|
127
|
+
Reactionary({
|
|
128
|
+
inputSchema: IdentityQueryProvidersSchema,
|
|
129
|
+
outputSchema: IdentityProviderSchema.array()
|
|
130
|
+
})
|
|
131
|
+
], FakeIdentityCapability.prototype, "listProviders", 1);
|
|
132
|
+
__decorateClass([
|
|
133
|
+
Reactionary({
|
|
134
|
+
inputSchema: IdentityMutationStartExternalLoginSchema,
|
|
135
|
+
outputSchema: ExternalLoginRedirectSchema
|
|
136
|
+
})
|
|
137
|
+
], FakeIdentityCapability.prototype, "startExternalLogin", 1);
|
|
138
|
+
__decorateClass([
|
|
139
|
+
Reactionary({
|
|
140
|
+
inputSchema: IdentityMutationCompleteExternalLoginSchema,
|
|
141
|
+
outputSchema: IdentitySchema
|
|
142
|
+
})
|
|
143
|
+
], FakeIdentityCapability.prototype, "completeExternalLogin", 1);
|
|
86
144
|
export {
|
|
87
145
|
FakeIdentityCapability
|
|
88
146
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/fake",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/Solteq/reactionary.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@reactionary/core": "0.12.
|
|
12
|
+
"@reactionary/core": "0.12.6",
|
|
13
13
|
"zod": "4.1.9",
|
|
14
14
|
"@faker-js/faker": "^9.8.0"
|
|
15
15
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Cache, type IdentityFactory, type IdentityFactoryOutput, type IdentityFactoryWithOutput, type IdentityMutationLogin, type IdentityMutationLogout, type IdentityMutationRegister, type IdentityQuerySelf, IdentityCapability, type RequestContext, type Result } from '@reactionary/core';
|
|
1
|
+
import { type Cache, type ExternalLoginRedirect, type IdentityConflictError, type IdentityMutationCompleteExternalLogin, type IdentityMutationStartExternalLogin, type IdentityProvider, type IdentityQueryProviders, type IdentityFactory, type IdentityFactoryOutput, type IdentityFactoryWithOutput, type IdentityMutationLogin, type IdentityMutationLogout, type IdentityMutationRegister, type IdentityQuerySelf, IdentityCapability, type RequestContext, type Result } from '@reactionary/core';
|
|
2
2
|
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
3
|
import type { FakeIdentityFactory } from '../factories/identity/identity.factory.js';
|
|
4
4
|
export declare class FakeIdentityCapability<TFactory extends IdentityFactory = FakeIdentityFactory> extends IdentityCapability<IdentityFactoryOutput<TFactory>> {
|
|
@@ -10,4 +10,7 @@ export declare class FakeIdentityCapability<TFactory extends IdentityFactory = F
|
|
|
10
10
|
login(_payload: IdentityMutationLogin): Promise<Result<IdentityFactoryOutput<TFactory>>>;
|
|
11
11
|
logout(_payload: IdentityMutationLogout): Promise<Result<IdentityFactoryOutput<TFactory>>>;
|
|
12
12
|
register(_payload: IdentityMutationRegister): Promise<Result<IdentityFactoryOutput<TFactory>>>;
|
|
13
|
+
listProviders(_payload: IdentityQueryProviders): Promise<Result<IdentityProvider[]>>;
|
|
14
|
+
startExternalLogin(payload: IdentityMutationStartExternalLogin): Promise<Result<ExternalLoginRedirect>>;
|
|
15
|
+
completeExternalLogin(payload: IdentityMutationCompleteExternalLogin): Promise<Result<IdentityFactoryOutput<TFactory>, IdentityConflictError>>;
|
|
13
16
|
}
|