@cinerino/sdk 3.62.0 → 3.65.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.
@@ -0,0 +1,66 @@
1
+ // tslint:disable:no-console
2
+ /**
3
+ * ユーザー認証
4
+ */
5
+ // tslint:disable-next-line:no-implicit-dependencies
6
+ import * as open from 'open';
7
+ import * as readline from 'readline';
8
+ import * as client from '../../../lib/';
9
+
10
+ export async function login() {
11
+ const auth = new client.auth.OAuth2({
12
+ domain: <string>process.env.TEST_CHILD_AUTHORIZE_SERVER_DOMAIN,
13
+ clientId: <string>process.env.TEST_CHILD_CLIENT_ID,
14
+ clientSecret: <string>process.env.TEST_CHILD_CLIENT_SECRET,
15
+ redirectUri: 'https://localhost/signIn',
16
+ logoutUri: 'https://localhost/signOut'
17
+ });
18
+
19
+ const scopes: string[] = [];
20
+ const state = '12345';
21
+ const codeVerifier = '12345';
22
+
23
+ let authUrl = auth.generateAuthUrl({
24
+ scopes: scopes,
25
+ state: state,
26
+ codeVerifier: codeVerifier
27
+ });
28
+ const signInUrl = new URL(authUrl);
29
+ authUrl = `${signInUrl.href}&identity_provider=`;
30
+
31
+ console.log('authUrl:', authUrl);
32
+ open(authUrl);
33
+
34
+ await new Promise<void>((resolve, reject) => {
35
+ const rl = readline.createInterface({
36
+ input: process.stdin,
37
+ output: process.stdout
38
+ });
39
+
40
+ rl.question('enter authorization code:\n', async (code) => {
41
+ rl.question('enter state:\n', async (givenState) => {
42
+ if (givenState !== state) {
43
+ reject(new Error('state not matched'));
44
+
45
+ return;
46
+ }
47
+
48
+ let credentials = await auth.getToken(code, codeVerifier);
49
+ console.log('credentials published', credentials);
50
+
51
+ auth.setCredentials(credentials);
52
+
53
+ credentials = await auth.refreshAccessToken();
54
+ console.log('credentials refreshed', credentials);
55
+
56
+ // rl.close();
57
+ resolve();
58
+ });
59
+ });
60
+ });
61
+
62
+ const logoutUrl = auth.generateLogoutUrl();
63
+ console.log('logoutUrl:', logoutUrl);
64
+
65
+ return auth;
66
+ }
@@ -66,7 +66,8 @@ async function main() {
66
66
 
67
67
  // 確定
68
68
  await payService.confirm({
69
- transactionNumber: transactionNumber
69
+ transactionNumber: transactionNumber,
70
+ potentialActions: { pay: { purpose: { typeOf: client.factory.order.OrderType.Order } } }
70
71
  });
71
72
  console.log('transaction confirmed');
72
73
  }
@@ -4,9 +4,16 @@ import * as httpStatus from 'http-status';
4
4
 
5
5
  import * as client from '../../../../lib/index';
6
6
  import * as auth from '../../auth/auth';
7
+ import * as authChild from '../../auth/authChild';
7
8
 
8
- // tslint:disable-next-line:max-func-body-length
9
9
  async function main() {
10
+ const childAuthClient = await authChild.login();
11
+ await childAuthClient.refreshAccessToken();
12
+ const childLoginTicket = childAuthClient.verifyIdToken({});
13
+ console.log('username is', childLoginTicket.getUsername());
14
+
15
+ // return;
16
+
10
17
  const authClient = await auth.login();
11
18
  await authClient.refreshAccessToken();
12
19
  const loginTicket = authClient.verifyIdToken({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "3.62.0",
3
+ "version": "3.65.0",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -97,7 +97,7 @@
97
97
  "watchify": "^3.11.1"
98
98
  },
99
99
  "dependencies": {
100
- "@cinerino/api-abstract-client": "3.62.0",
100
+ "@cinerino/api-abstract-client": "3.65.0",
101
101
  "debug": "^3.2.6",
102
102
  "http-status": "^1.4.2",
103
103
  "idtoken-verifier": "^2.0.3",