@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/LICENSE
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the
|
|
13
|
+
copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other
|
|
16
|
+
entities that control, are controlled by, or are under common control with
|
|
17
|
+
that entity. For the purposes of this definition, "control" means (i) the
|
|
18
|
+
power, direct or indirect, to cause the direction or management of such
|
|
19
|
+
entity, whether by contract or otherwise, or (ii) ownership of fifty percent
|
|
20
|
+
(50%) or more of the outstanding shares, or (iii) beneficial ownership of
|
|
21
|
+
such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
24
|
+
permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation source,
|
|
28
|
+
and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
|
|
135
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
136
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
137
|
+
except as required for reasonable and customary use in describing the
|
|
138
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
139
|
+
|
|
140
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
141
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
142
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
143
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
144
|
+
implied, including, without limitation, any warranties or conditions
|
|
145
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
146
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
147
|
+
appropriateness of using or redistributing the Work and assume any
|
|
148
|
+
risks associated with Your exercise of permissions under this License.
|
|
149
|
+
|
|
150
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
151
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
152
|
+
unless required by applicable law (such as deliberate and grossly
|
|
153
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
154
|
+
liable to You for damages, including any direct, indirect, special,
|
|
155
|
+
incidental, or consequential damages of any character arising as a
|
|
156
|
+
result of this License or out of the use or inability to use the
|
|
157
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
158
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
159
|
+
other commercial damages or losses), even if such Contributor
|
|
160
|
+
has been advised of the possibility of such damages.
|
|
161
|
+
|
|
162
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
163
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
164
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
165
|
+
or other liability obligations and/or rights consistent with this
|
|
166
|
+
License. However, in accepting such obligations, You may act only
|
|
167
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
168
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
169
|
+
defend, and hold each Contributor harmless for any liability
|
|
170
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
171
|
+
of your accepting any such warranty or additional liability.
|
|
172
|
+
|
|
173
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
# @hiofu/apply-sdk
|
|
2
|
+
|
|
3
|
+
Browser SDK for HIOFU's Apply with HSP1 flow.
|
|
4
|
+
|
|
5
|
+
It gives partner job boards, ATS products, and employer career sites a full candidate handoff flow:
|
|
6
|
+
|
|
7
|
+
- OAuth 2.0 Authorization Code with PKCE
|
|
8
|
+
- consented HSP1 variation review inside the popup
|
|
9
|
+
- immutable application snapshot creation
|
|
10
|
+
- idempotent application submission to HIOFU
|
|
11
|
+
- structured response payload for immediate partner-side handling
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
The SDK is a private package. Partners must be granted registry access before
|
|
16
|
+
installing it.
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm config set @hiofu:registry https://registry.npmjs.org/
|
|
20
|
+
npm config set //registry.npmjs.org/:_authToken $HIOFU_NPM_TOKEN
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm install @hiofu/apply-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Private preview (if not public yet)
|
|
28
|
+
|
|
29
|
+
If you received a private access token from HIOFU, add it to your project-level `.npmrc` so `npm install` can fetch the package:
|
|
30
|
+
|
|
31
|
+
```ini
|
|
32
|
+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
|
33
|
+
@hiofu:registry=https://registry.npmjs.org/
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then install as usual (with `NPM_TOKEN` set in your environment or CI).
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
Use sandbox keys for fake CV/HSP1 testing and live keys only after Hiofu grants
|
|
41
|
+
production access.
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { createApplyClient } from "@hiofu/apply-sdk";
|
|
45
|
+
|
|
46
|
+
const hiofu = createApplyClient({
|
|
47
|
+
environment: "sandbox",
|
|
48
|
+
publicKey: "pk_test_xxx",
|
|
49
|
+
redirectUri: "https://jobs.example.com/oauth/callback.html",
|
|
50
|
+
onComplete(result) {
|
|
51
|
+
console.log(result.applicationId, result.status);
|
|
52
|
+
},
|
|
53
|
+
onError(error) {
|
|
54
|
+
console.error(error.code, error.correlationId, error.message);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const result = await hiofu.apply({
|
|
59
|
+
externalJobId: "job_123",
|
|
60
|
+
externalEmployerId: "emp_456",
|
|
61
|
+
role: {
|
|
62
|
+
title: "Senior Engineer",
|
|
63
|
+
locations: ["London", "Remote"],
|
|
64
|
+
dimensions: { department: "Engineering" },
|
|
65
|
+
},
|
|
66
|
+
idempotencyKey: "apply_attempt_01JXYZ...",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(result.applicationId);
|
|
70
|
+
console.log(result.hiofuRoleId);
|
|
71
|
+
console.log(result.raw.snapshot);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
`createApplyClient` is the recommended partner API. It resolves the correct Hiofu URLs from `environment` and rejects key/environment mismatches before opening the popup.
|
|
77
|
+
|
|
78
|
+
- `environment` (required): `sandbox` or `production`.
|
|
79
|
+
- `publicKey` (required): Your publishable key, e.g. `pk_test_…` or `pk_live_…`.
|
|
80
|
+
- `redirectUri` (required): One of your registered callback URLs.
|
|
81
|
+
- `storage` (default `memory`): Token storage, either `memory` (cleared on reload) or `session` (persists for the browser session).
|
|
82
|
+
- `scopes` / `applyScopes` (optional): Default scopes for `authorize()` / `apply()`.
|
|
83
|
+
- `popupOptions.timeoutMs` (default 300_000): Popup wait limit in milliseconds.
|
|
84
|
+
- `onComplete(result)`: Receives the normalized apply result.
|
|
85
|
+
- `onCancel(context)`: Receives explicit user-cancel, popup-close, and timeout events.
|
|
86
|
+
- `onError(error)`: Receives a typed `HiofuApplyError`.
|
|
87
|
+
- `onEvent(event)`: Lifecycle hook for telemetry/UX.
|
|
88
|
+
|
|
89
|
+
`HiofuClient` remains available as the lower-level compatibility API using `clientId`, `hiofuOrigin`, and `apiBase`.
|
|
90
|
+
|
|
91
|
+
### Sandbox vs Production
|
|
92
|
+
|
|
93
|
+
Switch environments by key and base URLs. The SDK rejects mismatches before
|
|
94
|
+
opening the popup: `pk_test_*` must use sandbox URLs, and `pk_live_*` must use
|
|
95
|
+
production URLs.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const isSandbox = process.env.NODE_ENV !== "production"; // or your own flag
|
|
99
|
+
|
|
100
|
+
const hiofu = createApplyClient({
|
|
101
|
+
environment: isSandbox ? "sandbox" : "production",
|
|
102
|
+
publicKey: isSandbox ? "pk_test_xxx" : "pk_live_xxx",
|
|
103
|
+
redirectUri: `${window.location.origin}/oauth/callback.html`,
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## React
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import { HiofuProvider, useHiofuApply } from "@hiofu/apply-sdk/react";
|
|
111
|
+
|
|
112
|
+
export default function App() {
|
|
113
|
+
return (
|
|
114
|
+
<HiofuProvider
|
|
115
|
+
config={{
|
|
116
|
+
clientId: "pk_test_xxx",
|
|
117
|
+
hiofuOrigin: "https://sandbox.hiofu.com",
|
|
118
|
+
apiBase: "https://api.sandbox.hiofu.com/api",
|
|
119
|
+
redirectUri: "https://jobs.example.com/oauth/callback.html",
|
|
120
|
+
// Optional extras with sensible defaults
|
|
121
|
+
// storage: "session",
|
|
122
|
+
// applyScopes: ["applications.write", "passport.snapshot"],
|
|
123
|
+
// onEvent: (e) => console.debug("hiofu", e),
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
<ApplyButton />
|
|
127
|
+
</HiofuProvider>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function ApplyButton() {
|
|
132
|
+
const { apply, status, error, result } = useHiofuApply();
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<button
|
|
136
|
+
disabled={status === "authorising" || status === "submitting"}
|
|
137
|
+
onClick={() =>
|
|
138
|
+
apply({
|
|
139
|
+
jobId: "job_123",
|
|
140
|
+
jobTitle: "Senior Engineer",
|
|
141
|
+
employerId: "emp_456",
|
|
142
|
+
employerName: "Acme Inc",
|
|
143
|
+
role: {
|
|
144
|
+
externalRoleId: "job_123",
|
|
145
|
+
externalEmployerId: "emp_456",
|
|
146
|
+
title: "Senior Engineer",
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
>
|
|
151
|
+
{status === "submitting"
|
|
152
|
+
? "Submitting…"
|
|
153
|
+
: status === "authorising"
|
|
154
|
+
? "Authorising…"
|
|
155
|
+
: status === "success"
|
|
156
|
+
? "Submitted"
|
|
157
|
+
: "Apply with HIOFU"}
|
|
158
|
+
</button>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Error-aware button UX
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
function ApplyButton() {
|
|
167
|
+
const { apply, status, error, result, reset } = useHiofuApply();
|
|
168
|
+
return (
|
|
169
|
+
<div>
|
|
170
|
+
<button
|
|
171
|
+
disabled={status === "authorising" || status === "submitting"}
|
|
172
|
+
onClick={async () => {
|
|
173
|
+
try {
|
|
174
|
+
await apply({
|
|
175
|
+
jobId: "job_123",
|
|
176
|
+
jobTitle: "Senior Engineer",
|
|
177
|
+
employerId: "emp_456",
|
|
178
|
+
employerName: "Acme Inc",
|
|
179
|
+
});
|
|
180
|
+
} catch {}
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
{status === "submitting"
|
|
184
|
+
? "Submitting…"
|
|
185
|
+
: status === "authorising"
|
|
186
|
+
? "Authorising…"
|
|
187
|
+
: status === "success"
|
|
188
|
+
? "Submitted"
|
|
189
|
+
: "Apply with HIOFU"}
|
|
190
|
+
</button>
|
|
191
|
+
{status === "error" && <p role="alert">{error?.message}</p>}
|
|
192
|
+
{status === "success" && <p>Application ID: {result?.application.id}</p>}
|
|
193
|
+
{(status === "error" || status === "success") && (
|
|
194
|
+
<button onClick={reset}>Try again</button>
|
|
195
|
+
)}
|
|
196
|
+
</div>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Hosted Script
|
|
202
|
+
|
|
203
|
+
```html
|
|
204
|
+
<script
|
|
205
|
+
src="https://cdn.hiofu.com/apply-sdk.global.js"
|
|
206
|
+
data-client-id="pk_test_xxx"
|
|
207
|
+
data-hiofu-origin="https://sandbox.hiofu.com"
|
|
208
|
+
data-api-base="https://api.sandbox.hiofu.com/api"
|
|
209
|
+
data-redirect-uri="https://jobs.example.com/oauth/callback.html"
|
|
210
|
+
></script>
|
|
211
|
+
|
|
212
|
+
<button
|
|
213
|
+
data-hiofu-apply
|
|
214
|
+
data-job-id="job_123"
|
|
215
|
+
data-job-title="Senior Engineer"
|
|
216
|
+
data-employer-id="emp_456"
|
|
217
|
+
data-employer-name="Acme Inc"
|
|
218
|
+
data-external-role-id="job_123"
|
|
219
|
+
data-external-employer-id="emp_456"
|
|
220
|
+
data-role-department="Engineering"
|
|
221
|
+
data-role-locations="London,Remote"
|
|
222
|
+
>
|
|
223
|
+
Apply with HIOFU
|
|
224
|
+
</button>
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Environments
|
|
228
|
+
|
|
229
|
+
| Mode | Client ID | Hiofu origin | API base |
|
|
230
|
+
| --- | --- | --- | --- |
|
|
231
|
+
| Sandbox | `pk_test_*` | `https://sandbox.hiofu.com` | `https://api.sandbox.hiofu.com/api` |
|
|
232
|
+
| Production | `pk_live_*` | `https://hiofu.com` | `https://api.hiofu.com/api` |
|
|
233
|
+
|
|
234
|
+
`pk_test_*` is for fake sandbox data only. `pk_live_*` is for live candidate
|
|
235
|
+
and employer data after Hiofu production approval.
|
|
236
|
+
|
|
237
|
+
## Role Capture
|
|
238
|
+
|
|
239
|
+
Partners should pass their own external role identifiers in `role`. Hiofu maps
|
|
240
|
+
those identifiers to an internal organization and role before an application is
|
|
241
|
+
created. If the role is not mapped, the API rejects the submit request with a
|
|
242
|
+
role mapping error and no application is created.
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
await hiofu.apply({
|
|
246
|
+
jobId: "job_123",
|
|
247
|
+
jobTitle: "Senior Engineer",
|
|
248
|
+
employerId: "emp_456",
|
|
249
|
+
employerName: "Acme Inc",
|
|
250
|
+
role: {
|
|
251
|
+
externalRoleId: "job_123",
|
|
252
|
+
externalEmployerId: "emp_456",
|
|
253
|
+
title: "Senior Engineer",
|
|
254
|
+
description: "Build user-facing product surfaces.",
|
|
255
|
+
locations: ["London", "Remote"],
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Callback Handling
|
|
261
|
+
|
|
262
|
+
Register a callback page (e.g. `https://jobs.example.com/oauth/callback.html`) in your HIOFU partner settings. The page should relay the OAuth result back to the opener. Minimal example:
|
|
263
|
+
|
|
264
|
+
```html
|
|
265
|
+
<!doctype html>
|
|
266
|
+
<html lang="en">
|
|
267
|
+
<meta charset="UTF-8" />
|
|
268
|
+
<title>Returning…</title>
|
|
269
|
+
<body>
|
|
270
|
+
Returning you to the partner site…
|
|
271
|
+
<script>
|
|
272
|
+
(() => {
|
|
273
|
+
const p = new URLSearchParams(window.location.search);
|
|
274
|
+
const payload = {
|
|
275
|
+
type: "hiofu_oauth",
|
|
276
|
+
code: p.get("code"),
|
|
277
|
+
state: p.get("state"),
|
|
278
|
+
error: p.get("error"),
|
|
279
|
+
variationId: p.get("variation_id"),
|
|
280
|
+
};
|
|
281
|
+
if (window.opener) {
|
|
282
|
+
try {
|
|
283
|
+
window.opener.postMessage(payload, window.location.origin);
|
|
284
|
+
} catch {}
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
if (typeof BroadcastChannel !== "undefined") {
|
|
288
|
+
const ch = new BroadcastChannel("hiofu_oauth");
|
|
289
|
+
ch.postMessage(payload);
|
|
290
|
+
ch.close();
|
|
291
|
+
}
|
|
292
|
+
} catch {}
|
|
293
|
+
try {
|
|
294
|
+
localStorage.setItem("hiofu_oauth_result", JSON.stringify(payload));
|
|
295
|
+
} catch {}
|
|
296
|
+
setTimeout(() => {
|
|
297
|
+
try {
|
|
298
|
+
window.close();
|
|
299
|
+
} catch {}
|
|
300
|
+
}, 150);
|
|
301
|
+
})();
|
|
302
|
+
</script>
|
|
303
|
+
</body>
|
|
304
|
+
</html>
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Scopes
|
|
308
|
+
|
|
309
|
+
- `profile.basic`: minimal profile summary intended for partner-side apply UX
|
|
310
|
+
- `profile.full`: sanitised HSP1 profile summary including skills and redacted work/education history
|
|
311
|
+
- `evidence.read`: evidence titles, types, and aggregate trust signals
|
|
312
|
+
- `applications.write`: submit an application on the candidate's behalf
|
|
313
|
+
- `passport.snapshot`: create and return an immutable, partner-safe hiring snapshot with summary previews
|
|
314
|
+
|
|
315
|
+
## Apply Flow Behaviour
|
|
316
|
+
|
|
317
|
+
`apply()` requests the minimal application bundle by default:
|
|
318
|
+
|
|
319
|
+
- `applications.write`
|
|
320
|
+
- `passport.snapshot`
|
|
321
|
+
|
|
322
|
+
If no `variationId` is passed, the popup asks the candidate which HSP1 view to share and carries that exact selection through the final application submission.
|
|
323
|
+
|
|
324
|
+
Returned payload highlights:
|
|
325
|
+
|
|
326
|
+
- `application`: the HIOFU application record
|
|
327
|
+
- `sharedView`, `versionNumber`, and `snapshot`: immutable snapshot context plus safe hiring previews
|
|
328
|
+
- `profile`, `evidence`, `snapshot`: minimised partner-consumable response data based on granted scopes
|
|
329
|
+
- `delivery`: whether HIOFU also queued webhook delivery or returned response-only data
|
|
330
|
+
- `idempotencyKey`: the exact key used for this apply attempt
|
|
331
|
+
|
|
332
|
+
## Security Notes
|
|
333
|
+
|
|
334
|
+
- Register a partner-owned callback page like `https://jobs.example.com/oauth/callback.html` and pass it explicitly as `redirectUri`.
|
|
335
|
+
- Browser integrations receive a short-lived access token only through the SDK runtime. Refresh tokens are never exposed to partner UI code.
|
|
336
|
+
- The SDK does not inject third-party fonts or global styles into partner pages. Keep typography ownership inside your app shell.
|
|
337
|
+
- Do not log raw application payloads in production UIs.
|
|
338
|
+
- Pass a stable partner-generated `idempotencyKey` when you already have an application-attempt identifier.
|
|
339
|
+
- If you omit `idempotencyKey`, the SDK generates one for you and mirrors it into both the request header and body.
|
|
340
|
+
- The SDK defaults to in-memory token storage. Only opt into session storage if your threat model explicitly allows it.
|
|
341
|
+
- The popup times out after 5 minutes by default. Override `authorizeTimeoutMs` if your flow needs a different review window.
|
|
342
|
+
|
|
343
|
+
## Events
|
|
344
|
+
|
|
345
|
+
Subscribe to SDK lifecycle events when you want to build custom UX around the flow:
|
|
346
|
+
|
|
347
|
+
- `popup_opened`
|
|
348
|
+
- `popup_result_received`
|
|
349
|
+
- `popup_closed`
|
|
350
|
+
- `token_issued`
|
|
351
|
+
- `apply_started`
|
|
352
|
+
- `apply_submitting`
|
|
353
|
+
- `apply_success`
|
|
354
|
+
- `apply_error`
|
|
355
|
+
|
|
356
|
+
## Brand Helpers
|
|
357
|
+
|
|
358
|
+
The SDK exports HIOFU brand constants and an inline SVG mark:
|
|
359
|
+
|
|
360
|
+
```ts
|
|
361
|
+
import {
|
|
362
|
+
HIOFU_BRAND_COLOR,
|
|
363
|
+
HIOFU_BUTTON_LABEL,
|
|
364
|
+
HIOFU_WORDMARK,
|
|
365
|
+
HIOFU_TAGLINE,
|
|
366
|
+
hiofuLogoSvg,
|
|
367
|
+
} from "@hiofu/apply-sdk";
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Examples in this repo load Geist explicitly. Production partner apps should choose their own font-loading strategy rather than relying on the SDK to inject one.
|
|
371
|
+
|
|
372
|
+
## Examples
|
|
373
|
+
|
|
374
|
+
See [`partner-examples/`](../partner-examples) for working integrations: Next.js, static HTML, vanilla TS SPA, and webhook receiver examples.
|
|
375
|
+
|
|
376
|
+
## Errors
|
|
377
|
+
|
|
378
|
+
- `HiofuConfigurationError`: Thrown before network requests when SDK config is invalid, including `hiofu.environment_mismatch`.
|
|
379
|
+
- `HiofuApiError`: Thrown for HTTP errors from the partner API. Includes `status` and parsed `body` when available.
|
|
380
|
+
- Popup errors: "Popup blocked" (user agent blocks window.open), "Authorization timed out" (no result within `authorizeTimeoutMs`).
|
|
381
|
+
|
|
382
|
+
```ts
|
|
383
|
+
import {
|
|
384
|
+
HiofuClient,
|
|
385
|
+
HiofuApiError,
|
|
386
|
+
HiofuConfigurationError,
|
|
387
|
+
} from "@hiofu/apply-sdk";
|
|
388
|
+
|
|
389
|
+
const hiofu = new HiofuClient({
|
|
390
|
+
clientId: "pk_live_xxx",
|
|
391
|
+
redirectUri: `${location.origin}/oauth/callback.html`,
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
try {
|
|
395
|
+
const res = await hiofu.apply({
|
|
396
|
+
jobId: "job_123",
|
|
397
|
+
jobTitle: "Senior Engineer",
|
|
398
|
+
employerId: "emp_456",
|
|
399
|
+
employerName: "Acme Inc",
|
|
400
|
+
idempotencyKey: "apply_attempt_01JXYZ…",
|
|
401
|
+
});
|
|
402
|
+
console.log(res.application.id);
|
|
403
|
+
} catch (err) {
|
|
404
|
+
if (err instanceof HiofuConfigurationError) {
|
|
405
|
+
console.warn("SDK config error", err.code, err.details);
|
|
406
|
+
} else if (err instanceof HiofuApiError) {
|
|
407
|
+
// Inspect HTTP layer
|
|
408
|
+
console.warn("API error", err.status, err.body);
|
|
409
|
+
if (err.status === 401) {
|
|
410
|
+
// Not authorised; ask user to try again
|
|
411
|
+
}
|
|
412
|
+
if (err.status === 409) {
|
|
413
|
+
// Duplicate idempotency key; treat as success or fetch the prior result
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
// Popup blocked / timed out / generic runtime error
|
|
417
|
+
console.error(err.message);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
```
|