feathers-ucan 0.1.17 → 0.1.20
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/lib/auth-service/index.d.ts +14 -14
- package/lib/auth-service/index.js +1 -1
- package/lib/auth-service/ucan-strategy.d.ts +34 -35
- package/lib/auth-service.cjs +3 -2
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/methods.d.ts +33 -33
- package/lib/core.cjs +3 -2
- package/lib/env/version.d.ts +1 -1
- package/lib/hooks/index.d.ts +2 -2
- package/lib/hooks/index.js +1 -1
- package/lib/hooks/ucan-auth.d.ts +75 -74
- package/lib/hooks/update-ucan.d.ts +1 -1
- package/lib/hooks.cjs +19 -2
- package/lib/index.cjs +1019 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.modern.js +997 -1
- package/lib/index.modern.js.map +1 -1
- package/lib/index.umd.js +1022 -1
- package/lib/index.umd.js.map +1 -1
- package/lib/types/index.d.ts +3 -6
- package/lib/types.cjs +1 -2
- package/lib/utils/check-exists.d.ts +10 -8
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils.cjs +3 -2
- package/package.json +3 -3
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { AuthenticationParams, AuthenticationRequest, AuthenticationService } from '@feathersjs/authentication';
|
|
2
|
-
|
|
3
|
-
export declare class NotAuthError extends Error {
|
|
4
|
-
constructor(message?: string);
|
|
5
|
-
}
|
|
6
|
-
export type AuthServiceOptions = {
|
|
7
|
-
NotAuthenticated?: any;
|
|
8
|
-
};
|
|
9
|
-
export * from './ucan-strategy';
|
|
10
|
-
export declare class AuthService extends AuthenticationService {
|
|
11
|
-
options: AuthServiceOptions;
|
|
12
|
-
constructor(app: any, configKey?: string, opts?:
|
|
13
|
-
create(data: AuthenticationRequest, params?: AuthenticationParams): Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
14
|
-
}
|
|
1
|
+
import { AuthenticationParams, AuthenticationRequest, AuthenticationService } from '@feathersjs/authentication';
|
|
2
|
+
|
|
3
|
+
export declare class NotAuthError extends Error {
|
|
4
|
+
constructor(message?: string);
|
|
5
|
+
}
|
|
6
|
+
export type AuthServiceOptions = {
|
|
7
|
+
NotAuthenticated?: any;
|
|
8
|
+
};
|
|
9
|
+
export * from './ucan-strategy';
|
|
10
|
+
export declare class AuthService extends AuthenticationService {
|
|
11
|
+
options: AuthServiceOptions;
|
|
12
|
+
constructor(app: any, configKey?: string, opts?: any & AuthServiceOptions);
|
|
13
|
+
create(data: AuthenticationRequest, params?: AuthenticationParams): Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
14
|
+
}
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
* @param
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
1
|
+
import { IncomingMessage } from 'http';
|
|
2
|
+
import { AuthenticationBase, AuthenticationBaseStrategy, AuthenticationRequest, AuthenticationResult, ConnectionEvent } from '@feathersjs/authentication';
|
|
3
|
+
export declare class NotAuthError extends Error {
|
|
4
|
+
constructor(message?: string);
|
|
5
|
+
}
|
|
6
|
+
type AnyObj = {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
export declare class UcanStrategy extends AuthenticationBaseStrategy {
|
|
10
|
+
expirationTimers: WeakMap<object, any>;
|
|
11
|
+
setAuthentication(auth: AuthenticationBase): void;
|
|
12
|
+
get configuration(): any;
|
|
13
|
+
handleConnection(event: ConnectionEvent, connection: any, authResult?: AuthenticationResult): Promise<void>;
|
|
14
|
+
verifyConfiguration(): void;
|
|
15
|
+
getEntityQuery(_params: any): Promise<{}>;
|
|
16
|
+
/**
|
|
17
|
+
* Return the entity for a given id
|
|
18
|
+
* @param id The id to use
|
|
19
|
+
* @param params Service call parameters
|
|
20
|
+
*/
|
|
21
|
+
getEntity(id: string, params: any): Promise<any>;
|
|
22
|
+
getEntityId(authResult: AuthenticationResult, _params: AnyObj): Promise<any>;
|
|
23
|
+
authenticate(authentication: AuthenticationRequest, params: AnyObj): Promise<{
|
|
24
|
+
accessToken: any;
|
|
25
|
+
authentication: {
|
|
26
|
+
strategy: string;
|
|
27
|
+
accessToken: any;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
parse(req: IncomingMessage): Promise<{
|
|
31
|
+
strategy: string | undefined;
|
|
32
|
+
accessToken: string;
|
|
33
|
+
} | null>;
|
|
34
|
+
}
|
package/lib/auth-service.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
const { AuthService, NotAuthError, UcanStrategy } = require('./index.cjs');
|
|
3
|
+
module.exports = { AuthService, NotAuthError, UcanStrategy };
|
package/lib/core/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './methods';
|
|
1
|
+
export * from './methods';
|
package/lib/core/index.js
CHANGED
package/lib/core/methods.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
export type Id = number | string;
|
|
3
|
-
export type NullableId = Id | null;
|
|
4
|
-
export type CallFindResult<T =
|
|
5
|
-
total: number;
|
|
6
|
-
limit: number;
|
|
7
|
-
skip: number;
|
|
8
|
-
data: Array<T>;
|
|
9
|
-
};
|
|
10
|
-
export type AnyParams = Iterable<
|
|
11
|
-
declare type CoreOpts = {
|
|
12
|
-
skipJoins?: boolean;
|
|
13
|
-
admin_pass?: boolean;
|
|
14
|
-
};
|
|
15
|
-
export declare class CoreCall {
|
|
16
|
-
context: any;
|
|
17
|
-
service: string;
|
|
18
|
-
core:
|
|
19
|
-
entity: string;
|
|
20
|
-
constructor(service: string, context: any, coreOptions?: CoreOpts);
|
|
21
|
-
get(id: NullableId, params?:
|
|
22
|
-
find(params?:
|
|
23
|
-
create(data:
|
|
24
|
-
patch(id: NullableId, data:
|
|
25
|
-
update(id: NullableId, data:
|
|
26
|
-
remove(id: NullableId, params?:
|
|
27
|
-
_get(id: NullableId, params?:
|
|
28
|
-
_find(params?:
|
|
29
|
-
_create(data:
|
|
30
|
-
_patch(id: NullableId, data:
|
|
31
|
-
_update(id: NullableId, data:
|
|
32
|
-
_remove(id: NullableId, params?:
|
|
33
|
-
}
|
|
1
|
+
|
|
2
|
+
export type Id = number | string;
|
|
3
|
+
export type NullableId = Id | null;
|
|
4
|
+
export type CallFindResult<T = any> = {
|
|
5
|
+
total: number;
|
|
6
|
+
limit: number;
|
|
7
|
+
skip: number;
|
|
8
|
+
data: Array<T>;
|
|
9
|
+
};
|
|
10
|
+
export type AnyParams = Iterable<any>;
|
|
11
|
+
declare type CoreOpts = {
|
|
12
|
+
skipJoins?: boolean;
|
|
13
|
+
admin_pass?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare class CoreCall {
|
|
16
|
+
context: any;
|
|
17
|
+
service: string;
|
|
18
|
+
core: any;
|
|
19
|
+
entity: string;
|
|
20
|
+
constructor(service: string, context: any, coreOptions?: CoreOpts);
|
|
21
|
+
get(id: NullableId, params?: any): Promise<any>;
|
|
22
|
+
find(params?: any): Promise<any>;
|
|
23
|
+
create(data: any, params?: any): Promise<any>;
|
|
24
|
+
patch(id: NullableId, data: any, params?: any): Promise<any>;
|
|
25
|
+
update(id: NullableId, data: any, params?: any): Promise<any>;
|
|
26
|
+
remove(id: NullableId, params?: any): Promise<any>;
|
|
27
|
+
_get(id: NullableId, params?: any): Promise<any>;
|
|
28
|
+
_find(params?: any): Promise<any>;
|
|
29
|
+
_create(data: any, params?: any): Promise<any>;
|
|
30
|
+
_patch(id: NullableId, data: any, params?: any): Promise<any>;
|
|
31
|
+
_update(id: NullableId, data: any, params?: any): Promise<any>;
|
|
32
|
+
_remove(id: NullableId, params?: any): Promise<any>;
|
|
33
|
+
}
|
package/lib/core.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
const { CoreCall } = require('./index.cjs');
|
|
3
|
+
module.exports = { CoreCall };
|
package/lib/env/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.20";
|
package/lib/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ucan-auth';
|
|
2
|
-
export * from './update-ucan';
|
|
1
|
+
export * from './ucan-auth';
|
|
2
|
+
export * from './update-ucan';
|
package/lib/hooks/index.js
CHANGED
package/lib/hooks/ucan-auth.d.ts
CHANGED
|
@@ -1,74 +1,75 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Capability, VerifyOptions } from 'symbol-ucan';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export declare type
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export type
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
export declare const
|
|
55
|
-
export declare const
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export declare
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export declare const
|
|
74
|
-
export declare const
|
|
1
|
+
import type { HookContext } from '../types';
|
|
2
|
+
import { Capability, VerifyOptions } from 'symbol-ucan';
|
|
3
|
+
|
|
4
|
+
export type UcanAuthConfig = {
|
|
5
|
+
entity: string;
|
|
6
|
+
service: string;
|
|
7
|
+
client_ucan: string;
|
|
8
|
+
ucan_aud: string;
|
|
9
|
+
ucan_path: string;
|
|
10
|
+
core_path: string;
|
|
11
|
+
defaultHierPart: string;
|
|
12
|
+
defaultScheme: string;
|
|
13
|
+
};
|
|
14
|
+
type AnyAuth = '*';
|
|
15
|
+
export declare const anyAuth: AnyAuth;
|
|
16
|
+
type NoThrow = '$';
|
|
17
|
+
export declare const noThrow: NoThrow;
|
|
18
|
+
export type CapabilityParts = Partial<Capability> | [string, Array<string> | string];
|
|
19
|
+
export declare type LoginPassOption = [Array<string>, Array<string> | '*'];
|
|
20
|
+
export declare type UcanAuthOptions = {
|
|
21
|
+
creatorPass?: '*' | Array<string>;
|
|
22
|
+
loginPass?: Array<LoginPassOption>;
|
|
23
|
+
or?: '*' | Array<string>;
|
|
24
|
+
adminPass?: Array<string>;
|
|
25
|
+
noThrow?: boolean;
|
|
26
|
+
log?: boolean;
|
|
27
|
+
existingParams?: any;
|
|
28
|
+
specialChange?: Array<string> | AnyAuth;
|
|
29
|
+
cap_subjects?: Array<string>;
|
|
30
|
+
audience?: string;
|
|
31
|
+
};
|
|
32
|
+
type RequiredCapability = {
|
|
33
|
+
capability: Capability;
|
|
34
|
+
rootIssuer: string;
|
|
35
|
+
};
|
|
36
|
+
export type UcanCap = Array<CapabilityParts> | AnyAuth | NoThrow;
|
|
37
|
+
export type UcanAllArgs = {
|
|
38
|
+
all?: UcanCap;
|
|
39
|
+
get?: UcanCap;
|
|
40
|
+
find?: UcanCap;
|
|
41
|
+
create?: UcanCap;
|
|
42
|
+
patch?: UcanCap;
|
|
43
|
+
update?: UcanCap;
|
|
44
|
+
remove?: UcanCap;
|
|
45
|
+
};
|
|
46
|
+
type VerifyOne = {
|
|
47
|
+
ucan: string;
|
|
48
|
+
} & VerifyOptions;
|
|
49
|
+
type VerifyRes = {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
value?: Array<any>;
|
|
52
|
+
err?: Array<any>;
|
|
53
|
+
};
|
|
54
|
+
export declare const noThrowAuth: <S>(context: HookContext<S>) => Promise<HookContext<S>>;
|
|
55
|
+
export declare const bareAuth: <S>(context: HookContext<S>) => Promise<HookContext<S>>;
|
|
56
|
+
export declare const orVerifyLoop: (arr: Array<VerifyOne>, log?: boolean) => Promise<VerifyRes>;
|
|
57
|
+
export type VerifyConfig = {
|
|
58
|
+
client_ucan: string;
|
|
59
|
+
ucan_aud: string;
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
};
|
|
62
|
+
export declare const verifyAgainstReqs: <S>(reqs: Array<RequiredCapability>, config: VerifyConfig, options?: UcanAuthOptions) => (context: HookContext<S>) => Promise<VerifyRes>;
|
|
63
|
+
export type CapabilityModelConfig = {
|
|
64
|
+
defaultScheme: string;
|
|
65
|
+
defaultHierPart: string;
|
|
66
|
+
secret: string;
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
};
|
|
69
|
+
export declare const modelCapabilities: (reqs: Array<CapabilityParts>, config: CapabilityModelConfig) => Array<RequiredCapability>;
|
|
70
|
+
export declare type PassConfig = {
|
|
71
|
+
loginConfig?: VerifyConfig;
|
|
72
|
+
};
|
|
73
|
+
export declare const checkUcan: (requiredCapabilities: UcanCap, options?: UcanAuthOptions & PassConfig) => (context: HookContext) => Promise<HookContext>;
|
|
74
|
+
export declare const ucanAuth: <S>(requiredCapabilities?: UcanCap, options?: UcanAuthOptions) => (context: HookContext<S>) => Promise<HookContext<S>>;
|
|
75
|
+
export declare const allUcanAuth: <S>(methods: UcanAllArgs, options?: UcanAuthOptions) => (context: HookContext<S>) => Promise<HookContext<S>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const updateUcan: () => (context: any) => Promise<any>;
|
|
1
|
+
export declare const updateUcan: () => (context: any) => Promise<any>;
|
package/lib/hooks.cjs
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
const {
|
|
3
|
+
ucanAuth,
|
|
4
|
+
allUcanAuth,
|
|
5
|
+
noThrowAuth,
|
|
6
|
+
bareAuth,
|
|
7
|
+
updateUcan,
|
|
8
|
+
anyAuth,
|
|
9
|
+
noThrow
|
|
10
|
+
} = require('./index.cjs');
|
|
11
|
+
module.exports = {
|
|
12
|
+
ucanAuth,
|
|
13
|
+
allUcanAuth,
|
|
14
|
+
noThrowAuth,
|
|
15
|
+
bareAuth,
|
|
16
|
+
updateUcan,
|
|
17
|
+
anyAuth,
|
|
18
|
+
noThrow
|
|
19
|
+
};
|