socket-function 0.8.22 → 0.8.24
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/SocketFunction.ts +6 -11
- package/SocketFunctionTypes.ts +1 -1
- package/package.json +1 -1
- package/src/misc.ts +5 -1
package/SocketFunction.ts
CHANGED
|
@@ -43,12 +43,7 @@ export class SocketFunction {
|
|
|
43
43
|
shape: Shape
|
|
44
44
|
):
|
|
45
45
|
(
|
|
46
|
-
|
|
47
|
-
ExtractShape<ClassInstance, Shape> extends SocketExposedInterface
|
|
48
|
-
? SocketRegistered<ExtractShape<ClassInstance, Shape>, CallContext>
|
|
49
|
-
: {
|
|
50
|
-
error: "invalid shape";
|
|
51
|
-
} & PickByType<ExtractShape<ClassInstance, Shape>, string>
|
|
46
|
+
SocketRegistered<ExtractShape<ClassInstance, Shape>, CallContext>
|
|
52
47
|
) {
|
|
53
48
|
|
|
54
49
|
registerClass(classGuid, instance as SocketExposedInterface, shape as any as SocketExposedShape);
|
|
@@ -129,11 +124,11 @@ export class SocketFunction {
|
|
|
129
124
|
public static setDefaultHTTPCall<
|
|
130
125
|
Registered extends SocketRegistered,
|
|
131
126
|
FunctionName extends keyof Registered["nodes"][""] & string,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
>(
|
|
128
|
+
registered: Registered,
|
|
129
|
+
functionName: FunctionName,
|
|
130
|
+
...args: Args<Registered["nodes"][""][FunctionName]>
|
|
131
|
+
) {
|
|
137
132
|
setDefaultHTTPCall({
|
|
138
133
|
classGuid: registered._classGuid,
|
|
139
134
|
functionName,
|
package/SocketFunctionTypes.ts
CHANGED
|
@@ -67,7 +67,7 @@ export type CallContextType = {
|
|
|
67
67
|
[key: string]: unknown;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export interface SocketRegistered<ExposedType
|
|
70
|
+
export interface SocketRegistered<ExposedType = any, DynamicCallContext extends CallContextType = CallContextType> {
|
|
71
71
|
nodes: {
|
|
72
72
|
// NOTE: Don't pass around nodeId to other nodes, instead pass around NetworkLocation (which they
|
|
73
73
|
// then turn into a nodeId, which they can then check permissions on themself).
|
package/package.json
CHANGED
package/src/misc.ts
CHANGED
|
@@ -8,7 +8,11 @@ export function convertErrorStackToError(error: string): Error {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function sha256Hash(buffer: Buffer) {
|
|
11
|
-
|
|
11
|
+
if (isNode()) {
|
|
12
|
+
return crypto.createHash("sha256").update(buffer).digest("hex");
|
|
13
|
+
} else {
|
|
14
|
+
return window.crypto.subtle.digest("SHA-256", buffer);
|
|
15
|
+
}
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
|