@hiofu/apply-sdk 0.1.0
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 +173 -0
- package/README.md +420 -0
- package/dist/chunk-6YSWH4IM.js +647 -0
- package/dist/client-BD0-Mbnq.d.cts +279 -0
- package/dist/client-BD0-Mbnq.d.ts +279 -0
- package/dist/index.cjs +1036 -0
- package/dist/index.d.cts +158 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.global.js +1 -0
- package/dist/index.js +381 -0
- package/dist/react.cjs +748 -0
- package/dist/react.d.cts +20 -0
- package/dist/react.d.ts +20 -0
- package/dist/react.js +97 -0
- package/package.json +70 -0
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { c as HiofuConfig, H as HiofuClient, b as HiofuApplyResult, e as HiofuApplyOptions } from './client-BD0-Mbnq.cjs';
|
|
4
|
+
|
|
5
|
+
interface HiofuProviderProps {
|
|
6
|
+
config: HiofuConfig;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare function HiofuProvider({ config, children }: HiofuProviderProps): react.FunctionComponentElement<react.ProviderProps<HiofuClient | null>>;
|
|
10
|
+
declare function useHiofu(): HiofuClient;
|
|
11
|
+
interface UseHiofuApplyState {
|
|
12
|
+
status: "idle" | "authorising" | "submitting" | "success" | "error";
|
|
13
|
+
result: HiofuApplyResult | null;
|
|
14
|
+
error: Error | null;
|
|
15
|
+
apply: (opts: HiofuApplyOptions) => Promise<HiofuApplyResult>;
|
|
16
|
+
reset: () => void;
|
|
17
|
+
}
|
|
18
|
+
declare function useHiofuApply(): UseHiofuApplyState;
|
|
19
|
+
|
|
20
|
+
export { HiofuProvider, type HiofuProviderProps, type UseHiofuApplyState, useHiofu, useHiofuApply };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { c as HiofuConfig, H as HiofuClient, b as HiofuApplyResult, e as HiofuApplyOptions } from './client-BD0-Mbnq.js';
|
|
4
|
+
|
|
5
|
+
interface HiofuProviderProps {
|
|
6
|
+
config: HiofuConfig;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare function HiofuProvider({ config, children }: HiofuProviderProps): react.FunctionComponentElement<react.ProviderProps<HiofuClient | null>>;
|
|
10
|
+
declare function useHiofu(): HiofuClient;
|
|
11
|
+
interface UseHiofuApplyState {
|
|
12
|
+
status: "idle" | "authorising" | "submitting" | "success" | "error";
|
|
13
|
+
result: HiofuApplyResult | null;
|
|
14
|
+
error: Error | null;
|
|
15
|
+
apply: (opts: HiofuApplyOptions) => Promise<HiofuApplyResult>;
|
|
16
|
+
reset: () => void;
|
|
17
|
+
}
|
|
18
|
+
declare function useHiofuApply(): UseHiofuApplyState;
|
|
19
|
+
|
|
20
|
+
export { HiofuProvider, type HiofuProviderProps, type UseHiofuApplyState, useHiofu, useHiofuApply };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HiofuClient
|
|
3
|
+
} from "./chunk-6YSWH4IM.js";
|
|
4
|
+
|
|
5
|
+
// src/react.ts
|
|
6
|
+
import {
|
|
7
|
+
createContext,
|
|
8
|
+
createElement,
|
|
9
|
+
useCallback,
|
|
10
|
+
useContext,
|
|
11
|
+
useEffect,
|
|
12
|
+
useMemo,
|
|
13
|
+
useState
|
|
14
|
+
} from "react";
|
|
15
|
+
var Ctx = createContext(null);
|
|
16
|
+
function HiofuProvider({ config, children }) {
|
|
17
|
+
const client = useMemo(() => new HiofuClient(config), [
|
|
18
|
+
config.clientId,
|
|
19
|
+
config.hiofuOrigin,
|
|
20
|
+
config.apiBase,
|
|
21
|
+
config.redirectUri,
|
|
22
|
+
config.storage,
|
|
23
|
+
config.applyScopes?.join(","),
|
|
24
|
+
config.scopes?.join(","),
|
|
25
|
+
config.authorizeTimeoutMs,
|
|
26
|
+
config.onEvent
|
|
27
|
+
]);
|
|
28
|
+
return createElement(Ctx.Provider, { value: client }, children);
|
|
29
|
+
}
|
|
30
|
+
function useHiofu() {
|
|
31
|
+
const client = useContext(Ctx);
|
|
32
|
+
if (!client) {
|
|
33
|
+
throw new Error("useHiofu must be used inside <HiofuProvider>");
|
|
34
|
+
}
|
|
35
|
+
return client;
|
|
36
|
+
}
|
|
37
|
+
function useHiofuApply() {
|
|
38
|
+
const client = useHiofu();
|
|
39
|
+
const [status, setStatus] = useState("idle");
|
|
40
|
+
const [result, setResult] = useState(null);
|
|
41
|
+
const [error, setError] = useState(null);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
return client.subscribe((event) => {
|
|
44
|
+
switch (event.type) {
|
|
45
|
+
case "apply_started":
|
|
46
|
+
setStatus("authorising");
|
|
47
|
+
setResult(null);
|
|
48
|
+
setError(null);
|
|
49
|
+
break;
|
|
50
|
+
case "apply_submitting":
|
|
51
|
+
setStatus("submitting");
|
|
52
|
+
break;
|
|
53
|
+
case "apply_success":
|
|
54
|
+
setStatus("success");
|
|
55
|
+
setResult(event.result);
|
|
56
|
+
setError(null);
|
|
57
|
+
break;
|
|
58
|
+
case "apply_error":
|
|
59
|
+
setStatus("error");
|
|
60
|
+
setError(event.error);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}, [client]);
|
|
67
|
+
const apply = useCallback(
|
|
68
|
+
async (opts) => {
|
|
69
|
+
setStatus("authorising");
|
|
70
|
+
setError(null);
|
|
71
|
+
setResult(null);
|
|
72
|
+
try {
|
|
73
|
+
return await client.apply(opts);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
76
|
+
setError(e);
|
|
77
|
+
setStatus("error");
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
[client]
|
|
82
|
+
);
|
|
83
|
+
const reset = useCallback(() => {
|
|
84
|
+
setStatus("idle");
|
|
85
|
+
setResult(null);
|
|
86
|
+
setError(null);
|
|
87
|
+
}, []);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
void client.getAccessToken();
|
|
90
|
+
}, [client]);
|
|
91
|
+
return { status, result, error, apply, reset };
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
HiofuProvider,
|
|
95
|
+
useHiofu,
|
|
96
|
+
useHiofuApply
|
|
97
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hiofu/apply-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Partner-ready browser SDK for HIOFU Apply with OAuth, HSP1 review, and idempotent application submission.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"browser": "./dist/index.global.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./react": {
|
|
19
|
+
"types": "./dist/react.d.ts",
|
|
20
|
+
"import": "./dist/react.js",
|
|
21
|
+
"require": "./dist/react.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"dev": "tsup --watch",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"smoke:pack": "node scripts/smoke-package.mjs",
|
|
35
|
+
"prepack": "npm run build",
|
|
36
|
+
"prepublishOnly": "npm run typecheck && npm run smoke:pack"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"hiofu",
|
|
40
|
+
"oauth",
|
|
41
|
+
"apply",
|
|
42
|
+
"pkce",
|
|
43
|
+
"jobs",
|
|
44
|
+
"ats",
|
|
45
|
+
"talent",
|
|
46
|
+
"skills-passport"
|
|
47
|
+
],
|
|
48
|
+
"license": "Apache-2.0",
|
|
49
|
+
"homepage": "https://hiofu.com",
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "restricted"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": ">=18"
|
|
58
|
+
},
|
|
59
|
+
"peerDependenciesMeta": {
|
|
60
|
+
"react": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/react": "^19.2.14",
|
|
66
|
+
"react": "^19.0.0",
|
|
67
|
+
"tsup": "^8.0.0",
|
|
68
|
+
"typescript": "^5.4.0"
|
|
69
|
+
}
|
|
70
|
+
}
|