feathers-ucan 0.1.16 → 0.1.19

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