@nocobase/app-plugin-verification 0.0.0-stage → 0.1.0-beta.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/LICENSE.txt +127 -0
- package/README.md +6 -2
- package/dist/client/api.d.ts +18 -0
- package/dist/client/api.d.ts.map +1 -0
- package/dist/client/api.js +44 -0
- package/dist/client/api.js.map +1 -0
- package/dist/client/hooks.d.ts +17 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +91 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -0
- package/dist/database/migrations/.manifest.json +9 -0
- package/dist/database/migrations/202611250001_verification_create_tables.d.ts +4 -0
- package/dist/database/migrations/202611250001_verification_create_tables.d.ts.map +1 -0
- package/dist/database/migrations/202611250001_verification_create_tables.js +68 -0
- package/dist/database/migrations/202611250001_verification_create_tables.js.map +1 -0
- package/dist/server/config.d.ts +27 -0
- package/dist/server/config.d.ts.map +1 -0
- package/dist/server/config.js +38 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/contracts.d.ts +71 -0
- package/dist/server/contracts.d.ts.map +1 -0
- package/dist/server/contracts.js +2 -0
- package/dist/server/contracts.js.map +1 -0
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/plugin.d.ts +4 -0
- package/dist/server/plugin.d.ts.map +1 -0
- package/dist/server/plugin.js +15 -0
- package/dist/server/plugin.js.map +1 -0
- package/dist/server/providers/index.d.ts +4 -0
- package/dist/server/providers/index.d.ts.map +1 -0
- package/dist/server/providers/index.js +6 -0
- package/dist/server/providers/index.js.map +1 -0
- package/dist/server/providers/verification.d.ts +7 -0
- package/dist/server/providers/verification.d.ts.map +1 -0
- package/dist/server/providers/verification.js +59 -0
- package/dist/server/providers/verification.js.map +1 -0
- package/dist/server/routes/index.d.ts +5 -0
- package/dist/server/routes/index.d.ts.map +1 -0
- package/dist/server/routes/index.js +123 -0
- package/dist/server/routes/index.js.map +1 -0
- package/dist/server/routes/schemas.d.ts +9 -0
- package/dist/server/routes/schemas.d.ts.map +1 -0
- package/dist/server/routes/schemas.js +38 -0
- package/dist/server/routes/schemas.js.map +1 -0
- package/dist/server/services/verification.d.ts +64 -0
- package/dist/server/services/verification.d.ts.map +1 -0
- package/dist/server/services/verification.js +467 -0
- package/dist/server/services/verification.js.map +1 -0
- package/dist/server/tokens.d.ts +4 -0
- package/dist/server/tokens.d.ts.map +1 -0
- package/dist/server/tokens.js +3 -0
- package/dist/server/tokens.js.map +1 -0
- package/dist/shared/contracts.d.ts +27 -0
- package/dist/shared/contracts.d.ts.map +1 -0
- package/dist/shared/contracts.js +2 -0
- package/dist/shared/contracts.js.map +1 -0
- package/package.json +86 -3
- package/skills/nocobase-app-plugin-verification/SKILL.md +87 -0
- package/skills/nocobase-app-plugin-verification/references/client.md +115 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../server/contracts.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default } from './plugin.js';
|
|
2
|
+
export { defineVerificationConfig, type VerificationConfig } from './config.js';
|
|
3
|
+
export { changePhonePurpose } from './contracts.js';
|
|
4
|
+
export type * from './contracts.js';
|
|
5
|
+
export { verificationServiceToken } from './tokens.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,mBAAmB,gBAAgB,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAA2B,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../server/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,8BAA8B,CAAC;AAKtC,QAAA,MAAM,kBAAkB,EAAE,eAQxB,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { defineServerPlugin, } from '@nocobase/app-server/plugins';
|
|
3
|
+
import serviceProviders from './providers/index.js';
|
|
4
|
+
import routes from './routes/index.js';
|
|
5
|
+
const verificationPlugin = defineServerPlugin({
|
|
6
|
+
baseDir: path.resolve(import.meta.dirname, '..'),
|
|
7
|
+
packageName: '@nocobase/app-plugin-verification',
|
|
8
|
+
serviceProviders,
|
|
9
|
+
routes,
|
|
10
|
+
database: {
|
|
11
|
+
migrations: './database/migrations',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
export default verificationPlugin;
|
|
15
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../server/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,kBAAkB,GAEnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,kBAAkB,GAAoB,kBAAkB,CAAC;IAC7D,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC;IAChD,WAAW,EAAE,mCAAmC;IAChD,gBAAgB;IAChB,MAAM;IACN,QAAQ,EAAE;QACR,UAAU,EAAE,uBAAuB;KACpC;CACF,CAAC,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAIjF,eAAO,MAAM,gBAAgB,EAAE,SAAS,4BAA4B,EAEnE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/providers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAA4C;IACvE,oBAAoB;CACrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppPluginApplication } from '@nocobase/app-server/plugins';
|
|
2
|
+
import { ServiceProvider } from '@nocobase/service-provider';
|
|
3
|
+
export declare class VerificationProvider extends ServiceProvider<AppPluginApplication> {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
register(): void;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../server/providers/verification.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAM7D,qBAAa,oBAAqB,SAAQ,eAAe,CAAC,oBAAoB,CAAC;IAC7E,SAAgB,IAAI,EAAE,MAAM,CAAuC;IAEnD,QAAQ,IAAI,IAAI;CAkDjC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { notificationServiceToken, } from '@nocobase/app-plugin-notification';
|
|
2
|
+
import { isE164, userPhoneDirectoryToken, } from '@nocobase/app-plugin-notification-providers/sms';
|
|
3
|
+
import { cachingToken } from '@nocobase/app-server/caching';
|
|
4
|
+
import { loggingToken } from '@nocobase/app-server/logging';
|
|
5
|
+
import { secretsServiceToken } from '@nocobase/app-server/secrets';
|
|
6
|
+
import { databaseManagerToken } from '@nocobase/db';
|
|
7
|
+
import { ServiceProvider } from '@nocobase/service-provider';
|
|
8
|
+
import { DefaultVerificationService } from '../services/verification.js';
|
|
9
|
+
import { verificationServiceToken } from '../tokens.js';
|
|
10
|
+
export class VerificationProvider extends ServiceProvider {
|
|
11
|
+
name = '@nocobase/app-plugin-verification';
|
|
12
|
+
register() {
|
|
13
|
+
const { container, config } = this.app;
|
|
14
|
+
const createService = () => {
|
|
15
|
+
const counter = container
|
|
16
|
+
.resolve(cachingToken)
|
|
17
|
+
.getCounter({ namespace: 'verification-send' });
|
|
18
|
+
const logger = container.resolve(loggingToken).getLogger('verification');
|
|
19
|
+
return new DefaultVerificationService({
|
|
20
|
+
database: container.resolve(databaseManagerToken),
|
|
21
|
+
secrets: container.resolve(secretsServiceToken),
|
|
22
|
+
config: config.get('verification'),
|
|
23
|
+
incrementSender: (key, ttl) => counter.increment(key, 1, ttl),
|
|
24
|
+
audit: (event) => logger.info(event, 'Verification event.'),
|
|
25
|
+
sms: {
|
|
26
|
+
id: 'sms',
|
|
27
|
+
normalizeTarget: (target) => (isE164(target) ? target : undefined),
|
|
28
|
+
deliver: async ({ channel, target, template, code }) => {
|
|
29
|
+
const channels = config.get('notification')?.channels;
|
|
30
|
+
const destination = channels && Object.hasOwn(channels, channel)
|
|
31
|
+
? channels[channel]
|
|
32
|
+
: undefined;
|
|
33
|
+
if (!destination ||
|
|
34
|
+
('type' in destination
|
|
35
|
+
? destination.type
|
|
36
|
+
: destination.provider) !== 'sms' ||
|
|
37
|
+
destination.enabled === false) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const message = {
|
|
41
|
+
to: target,
|
|
42
|
+
template,
|
|
43
|
+
params: { code },
|
|
44
|
+
};
|
|
45
|
+
const [result] = await container
|
|
46
|
+
.resolve(notificationServiceToken)
|
|
47
|
+
.sendTransient({ channel, message });
|
|
48
|
+
return result?.status === 'accepted';
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
let service;
|
|
54
|
+
const resolve = () => (service ??= createService());
|
|
55
|
+
container.singleton(verificationServiceToken, resolve);
|
|
56
|
+
container.singleton(userPhoneDirectoryToken, resolve);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../server/providers/verification.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAEzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,MAAM,EACN,uBAAuB,GAExB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,oBAAo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/app-server/router';
|
|
2
|
+
import type { AppPluginApplication } from '@nocobase/app-server/plugins';
|
|
3
|
+
declare const routes: readonly AppApiRouteContribution<AppPluginApplication>[];
|
|
4
|
+
export default routes;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/routes/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAUL,KAAK,uBAAuB,EAC7B,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAmLzE,QAAA,MAAM,MAAM,EAAE,SAAS,uBAAuB,CAAC,oBAAoB,CAAC,EAEnE,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { authenticationToken, isServiceAccount, } from '@nocobase/app-plugin-authentication';
|
|
2
|
+
import { ApiError, apiErrorHandler, apiErrorResponse, apiValidator, cliRoute, dataResponse, defineApiRoutes, describeRoute, getClientAddress, } from '@nocobase/app-server/router';
|
|
3
|
+
import { Hono } from 'hono';
|
|
4
|
+
import { verificationError } from '../services/verification.js';
|
|
5
|
+
import { verificationServiceToken } from '../tokens.js';
|
|
6
|
+
import { phoneInput, phoneSchema, sendInput, stepUpInput, stepUpSchema, timingSchema, } from './schemas.js';
|
|
7
|
+
const tags = ['Verification'];
|
|
8
|
+
const sessionSecurity = [{ cookieAuth: [] }];
|
|
9
|
+
const sessionErrors = {
|
|
10
|
+
401: apiErrorResponse(401),
|
|
11
|
+
403: apiErrorResponse(403),
|
|
12
|
+
500: apiErrorResponse(500),
|
|
13
|
+
};
|
|
14
|
+
const verificationRoutes = defineApiRoutes(({ container }) => {
|
|
15
|
+
const router = new Hono();
|
|
16
|
+
const auth = container.resolve(authenticationToken);
|
|
17
|
+
const service = () => container.resolve(verificationServiceToken);
|
|
18
|
+
router.onError((error, context) => {
|
|
19
|
+
if (error instanceof ApiError &&
|
|
20
|
+
error.domain === 'verification' &&
|
|
21
|
+
error.code === 429) {
|
|
22
|
+
context.header('Retry-After', String(error.metadata?.retryAfterSeconds));
|
|
23
|
+
}
|
|
24
|
+
return apiErrorHandler(error, context);
|
|
25
|
+
});
|
|
26
|
+
router.use('/verification/*', async (context, next) => {
|
|
27
|
+
context.header('Cache-Control', 'no-store');
|
|
28
|
+
await next();
|
|
29
|
+
});
|
|
30
|
+
const personOnly = async (context, next) => {
|
|
31
|
+
const session = context.get('auth');
|
|
32
|
+
if (session &&
|
|
33
|
+
(isServiceAccount(session.user) ||
|
|
34
|
+
(await auth.isScopedSession(session, context.req.raw)))) {
|
|
35
|
+
throw verificationError('PERMISSION_DENIED', 'VERIFICATION_SESSION_REQUIRED', 'A signed-in person is required.');
|
|
36
|
+
}
|
|
37
|
+
await next();
|
|
38
|
+
};
|
|
39
|
+
router.post('/verification/codes/send', auth.optional(), personOnly, describeRoute({
|
|
40
|
+
tags,
|
|
41
|
+
summary: 'Request a verification code',
|
|
42
|
+
operationId: 'verificationSendCode',
|
|
43
|
+
description: 'Public scenes are anonymous and rate limited. Signed-in scenes act on the current person. The stepUp scene sends to their verified phone for the supplied purpose. HTTP 429 includes Retry-After and error.metadata.retryAt.',
|
|
44
|
+
security: [],
|
|
45
|
+
...cliRoute({ action: 'verification.codes/send', hidden: true }),
|
|
46
|
+
responses: {
|
|
47
|
+
200: dataResponse(timingSchema),
|
|
48
|
+
...sessionErrors,
|
|
49
|
+
429: apiErrorResponse(429),
|
|
50
|
+
503: apiErrorResponse(503),
|
|
51
|
+
},
|
|
52
|
+
}), apiValidator('json', sendInput), async (context) => {
|
|
53
|
+
const userId = context.get('auth')?.user.id;
|
|
54
|
+
const { phone, ...input } = context.req.valid('json');
|
|
55
|
+
return context.json({
|
|
56
|
+
data: await service().send({
|
|
57
|
+
...input,
|
|
58
|
+
target: phone,
|
|
59
|
+
userId,
|
|
60
|
+
clientAddress: userId
|
|
61
|
+
? undefined
|
|
62
|
+
: auth.clientAddress(context.req.raw, getClientAddress(context)),
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
router.post('/verification/stepUpTokens', auth.required(), personOnly, describeRoute({
|
|
67
|
+
tags,
|
|
68
|
+
summary: 'Exchange a code for a step-up credential',
|
|
69
|
+
operationId: 'verificationIssueStepUpToken',
|
|
70
|
+
description: 'Requires the current person’s session and the code sent to their verified phone for this purpose. The credential is returned once.',
|
|
71
|
+
security: sessionSecurity,
|
|
72
|
+
...cliRoute({
|
|
73
|
+
action: 'verification.stepUpTokens/create',
|
|
74
|
+
hidden: true,
|
|
75
|
+
}),
|
|
76
|
+
responses: {
|
|
77
|
+
200: dataResponse(stepUpSchema),
|
|
78
|
+
...sessionErrors,
|
|
79
|
+
503: apiErrorResponse(503),
|
|
80
|
+
},
|
|
81
|
+
}), apiValidator('json', stepUpInput), async (context) => context.json({
|
|
82
|
+
data: await service().issueStepUp({
|
|
83
|
+
...context.req.valid('json'),
|
|
84
|
+
userId: context.get('auth').user.id,
|
|
85
|
+
}),
|
|
86
|
+
}));
|
|
87
|
+
router.get('/verification/me/phone', auth.required(), personOnly, describeRoute({
|
|
88
|
+
tags,
|
|
89
|
+
summary: 'Get my verified phone',
|
|
90
|
+
operationId: 'verificationGetMyPhone',
|
|
91
|
+
description: 'Requires the current person’s session. The reply gives only the last four digits.',
|
|
92
|
+
security: sessionSecurity,
|
|
93
|
+
...cliRoute({ action: 'verification.phone/read', hidden: true }),
|
|
94
|
+
responses: { 200: dataResponse(phoneSchema), ...sessionErrors },
|
|
95
|
+
}), async (context) => context.json({
|
|
96
|
+
data: await service().getPhone(context.get('auth').user.id),
|
|
97
|
+
}));
|
|
98
|
+
router.put('/verification/me/phone', auth.required(), personOnly, describeRoute({
|
|
99
|
+
tags,
|
|
100
|
+
summary: 'Bind or change my verified phone',
|
|
101
|
+
operationId: 'verificationSetMyPhone',
|
|
102
|
+
description: 'Requires the current person’s session and a code sent to the new phone. To replace an existing verified phone, also supply a verification.changePhone credential in the X-Verification-Token header.',
|
|
103
|
+
security: sessionSecurity,
|
|
104
|
+
...cliRoute({ action: 'verification.phone/update', hidden: true }),
|
|
105
|
+
responses: {
|
|
106
|
+
200: dataResponse(phoneSchema),
|
|
107
|
+
...sessionErrors,
|
|
108
|
+
409: apiErrorResponse(409),
|
|
109
|
+
},
|
|
110
|
+
}), apiValidator('json', phoneInput), async (context) => context.json({
|
|
111
|
+
data: await service().bindPhone({
|
|
112
|
+
...context.req.valid('json'),
|
|
113
|
+
userId: context.get('auth').user.id,
|
|
114
|
+
token: context.req.header('X-Verification-Token'),
|
|
115
|
+
}),
|
|
116
|
+
}));
|
|
117
|
+
return new Hono().route('/', router);
|
|
118
|
+
});
|
|
119
|
+
const routes = [
|
|
120
|
+
verificationRoutes,
|
|
121
|
+
];
|
|
122
|
+
export default routes;
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GAEjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,aAAa,EACb,gBAAgB,GAEjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAA0B,MAAM,MAAM,CAAC;AAGpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EACL,UAAU,EACV,WAAW,EACX,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,MAAM,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;AAC9B,MAAM,eAAe,GAAG,CAAC,EAAE,UAA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AAC;AACvC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,GAA6D;IACvE,kBAAkB;CACnB,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { BindPhoneInput, CodeTiming, IssueStepUpTokenInput, PhoneView, SendVerificationCodeInput, StepUpCredential } from '../../shared/contracts.js';
|
|
3
|
+
export declare const sendInput: z.ZodType<SendVerificationCodeInput>;
|
|
4
|
+
export declare const stepUpInput: z.ZodType<IssueStepUpTokenInput>;
|
|
5
|
+
export declare const phoneInput: z.ZodType<BindPhoneInput>;
|
|
6
|
+
export declare const timingSchema: z.ZodType<CodeTiming>;
|
|
7
|
+
export declare const stepUpSchema: z.ZodType<StepUpCredential>;
|
|
8
|
+
export declare const phoneSchema: z.ZodType<PhoneView>;
|
|
9
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../server/routes/schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,qBAAqB,EACrB,SAAS,EACT,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AASnC,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,yBAAyB,CASzD,CAAC;AACH,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAGvD,CAAC;AACH,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAG/C,CAAC;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAG7C,CAAC;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAGnD,CAAC;AACH,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAE3C,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isE164 } from '@nocobase/app-plugin-notification-providers/sms';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { nameSchema } from '../config.js';
|
|
4
|
+
const otp = z
|
|
5
|
+
.string()
|
|
6
|
+
.regex(/^\d{6}$/)
|
|
7
|
+
.meta({
|
|
8
|
+
description: 'The six-digit code received over the registered channel.',
|
|
9
|
+
});
|
|
10
|
+
export const sendInput = z.strictObject({
|
|
11
|
+
scene: nameSchema,
|
|
12
|
+
phone: z.string().min(1).max(256).optional().meta({
|
|
13
|
+
description: 'Target in E.164 format for SMS. Omit for a verified-phone scene.',
|
|
14
|
+
}),
|
|
15
|
+
purpose: nameSchema
|
|
16
|
+
.optional()
|
|
17
|
+
.meta({ description: 'The registered purpose, required for stepUp.' }),
|
|
18
|
+
});
|
|
19
|
+
export const stepUpInput = z.strictObject({
|
|
20
|
+
purpose: nameSchema,
|
|
21
|
+
code: otp,
|
|
22
|
+
});
|
|
23
|
+
export const phoneInput = z.strictObject({
|
|
24
|
+
phone: z.string().refine(isE164, 'Expected an E.164 phone number.'),
|
|
25
|
+
code: otp,
|
|
26
|
+
});
|
|
27
|
+
export const timingSchema = z.object({
|
|
28
|
+
expiresAt: z.iso.datetime(),
|
|
29
|
+
resendAt: z.iso.datetime(),
|
|
30
|
+
});
|
|
31
|
+
export const stepUpSchema = z.object({
|
|
32
|
+
token: z.string(),
|
|
33
|
+
expiresAt: z.iso.datetime(),
|
|
34
|
+
});
|
|
35
|
+
export const phoneSchema = z.object({
|
|
36
|
+
phone: z.string().nullable(),
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../server/routes/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,E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CAAC,MAAM,EAAE;IACjB,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,CAAC,MAAM,CAAC;IACxD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ApiError, type ApiErrorStatus } from '@nocobase/app-server/router';
|
|
2
|
+
import type { SecretsService } from '@nocobase/app-server/secrets';
|
|
3
|
+
import { type DatabaseManager } from '@nocobase/db';
|
|
4
|
+
import { type VerificationConfig } from '../config.js';
|
|
5
|
+
import { type CodeTiming, type PhoneView, type StepUpCredential, type SendCodeInput, type StepUpScope, type VerificationMethod, type VerificationScene, type VerificationService, type VerifyCodeInput } from '../contracts.js';
|
|
6
|
+
interface Options {
|
|
7
|
+
readonly database: DatabaseManager;
|
|
8
|
+
readonly secrets: Pick<SecretsService, 'keyring'>;
|
|
9
|
+
readonly config?: VerificationConfig;
|
|
10
|
+
readonly sms: VerificationMethod;
|
|
11
|
+
readonly incrementSender: (key: string, ttl: number) => Promise<number>;
|
|
12
|
+
readonly audit: (event: {
|
|
13
|
+
event: string;
|
|
14
|
+
scene?: string;
|
|
15
|
+
userId?: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
readonly clock?: () => number;
|
|
18
|
+
}
|
|
19
|
+
export declare function verificationError(status: ApiErrorStatus, reason: string, message: string, metadata?: Record<string, unknown>): ApiError;
|
|
20
|
+
export declare class DefaultVerificationService implements VerificationService {
|
|
21
|
+
private readonly options;
|
|
22
|
+
private readonly methods;
|
|
23
|
+
private readonly scenes;
|
|
24
|
+
private readonly purposes;
|
|
25
|
+
private readonly config;
|
|
26
|
+
private readonly clock;
|
|
27
|
+
constructor(options: Options);
|
|
28
|
+
registerMethod(method: VerificationMethod): void;
|
|
29
|
+
registerScene(name: string, scene: VerificationScene): void;
|
|
30
|
+
registerStepUpPurpose(purpose: string, options?: {
|
|
31
|
+
ttlSeconds?: number;
|
|
32
|
+
}): void;
|
|
33
|
+
private addScene;
|
|
34
|
+
send(input: SendCodeInput): Promise<CodeTiming>;
|
|
35
|
+
verify(input: VerifyCodeInput): Promise<void>;
|
|
36
|
+
issueStepUp(input: StepUpScope & {
|
|
37
|
+
code: string;
|
|
38
|
+
}): Promise<StepUpCredential>;
|
|
39
|
+
consumeStepUp(input: StepUpScope & {
|
|
40
|
+
token?: string;
|
|
41
|
+
}): Promise<void>;
|
|
42
|
+
private checkCredential;
|
|
43
|
+
private consumeCredential;
|
|
44
|
+
getPhone(userId: string): Promise<PhoneView>;
|
|
45
|
+
bindPhone(input: {
|
|
46
|
+
userId: string;
|
|
47
|
+
phone: string;
|
|
48
|
+
code: string;
|
|
49
|
+
token?: string;
|
|
50
|
+
}): Promise<PhoneView>;
|
|
51
|
+
findUserIdByPhone(phone: string): Promise<string | undefined>;
|
|
52
|
+
find(userIds: readonly string[]): Promise<ReadonlyMap<string, string>>;
|
|
53
|
+
private phone;
|
|
54
|
+
private scene;
|
|
55
|
+
private purpose;
|
|
56
|
+
private challenge;
|
|
57
|
+
private reserveSender;
|
|
58
|
+
private reserveNumber;
|
|
59
|
+
private consumeCode;
|
|
60
|
+
private writeVersioned;
|
|
61
|
+
private audit;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../server/services/verification.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM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